com.opencms.defaults.master.genericsql
Class CmsDbAccess

java.lang.Object
  |
  +--com.opencms.defaults.master.genericsql.CmsDbAccess

public class CmsDbAccess
extends Object

This class provides methods to access the database in a generic way.


Field Summary
static String C_COS_PREFIX
           
protected  String m_backupPoolName
          The pool to access the backup ressources
protected  String m_onlinePoolName
          The pool to access the online ressources
protected  String m_poolName
          The pool to access offline ressources
protected  Properties m_queries
          The query properties for this accessmodule
protected  String m_rootChannel
          The root channel of the module
 
Constructor Summary
CmsDbAccess()
          Public empty constructor, call "init()" on this class afterwards.
CmsDbAccess(String poolName, String onlinePoolName, String backupPoolName)
          Constructs a new DbAccessObject.
 
Method Summary
 void changePermissions(CmsObject cms, CmsMasterContent content, CmsMasterDataSet dataset)
          Changes the perrmissions of the Master
protected  boolean checkAccess(CmsMasterContent content, boolean viewonly)
          Checks if read (and visible) permissions are granted.
protected  int computeProjectId(CmsObject cms, CmsMasterDataSet dataset)
          Computes the correct project id based on the channels.
 int copy(CmsObject cms, CmsMasterContent content, CmsMasterDataSet dataset, Vector mediaToAdd, Vector channelToAdd)
          Inserts a new row in the database with the copied dataset.
protected  Vector createVectorOfCd(ResultSet res, Class contentDefinitionClass, CmsObject cms)
          Returns a vector of contentdefinitions based on the sql resultset.
protected  Vector createVectorOfCd(ResultSet res, Class contentDefinitionClass, CmsObject cms, boolean viewonly)
          Returns a vector of contentdefinitions based on the sql resultset.
protected  Vector createVectorOfCd(Vector datasets, Class contentDefinitionClass, CmsObject cms)
          Returns a vector of contentdefinitions based on the sql resultset.
 void delete(CmsObject cms, CmsMasterContent content, CmsMasterDataSet dataset)
           
protected  void deleteAllChannels(int masterId)
          Deletes all channel lines for one master.
protected  void deleteAllMedia(int masterId)
          Deletes all media lines for one master.
 Connection getConnection(CmsObject cms)
          Returns the correct connection.
 Vector getHistory(CmsObject cms, Class contentDefinitionClass, int masterId, int subId)
          Returns a vector with all version of a master in the backup
 String getRootChannel()
          Get the root channel
 CmsMasterContent getVersionFromHistory(CmsObject cms, Class contentDefinitionClass, int masterId, int subId, int versionId)
          Returns the version of a master in the backup
 CmsMasterDataSet getVersionFromHistory(CmsObject cms, int masterId, int subId, int versionId)
          Returns the version of a master in the backup
 void init(String offline, String online, String backup)
          Initializes the DBAccessObject.
 void insert(CmsObject cms, CmsMasterContent content, CmsMasterDataSet dataset)
          Inserts a new row in the database with the dataset.
protected  boolean isOnlineProject(CmsObject cms)
          Returns true, if this is the onlineproject
protected  void publishBackupData(CmsObject cms, CmsMasterDataSet dataset, int subId, int versionId, long publishDate)
           
protected  void publishCopyData(CmsMasterDataSet dataset, int subId)
           
protected  void publishDeleteData(int masterId, int subId, String table)
           
protected  void publishOneLine(CmsObject cms, CmsMasterDataSet dataset, int subId, String contentDefinitionName, boolean enableHistory, int versionId, long publishingDate, Vector changedRessources, Vector changedModuleData)
           
 void publishProject(CmsObject cms, boolean enableHistory, int projectId, int versionId, long publishingDate, int subId, String contentDefinitionName, Vector changedRessources, Vector changedModuleData)
          Publishes all ressources for this project Publishes all modified content definitions for this project.
 void publishResource(CmsObject cms, CmsMasterDataSet dataset, int subId, String contentDefinitionName, boolean enableHistory, int versionId, long publishingDate, Vector changedResources, Vector changedModuleData)
          Publishes a single content definition
 void read(CmsObject cms, CmsMasterContent content, CmsMasterDataSet dataset, int masterId)
           
 Vector readAllByChannel(CmsObject cms, int channelId, int subId)
          Reads all content definitions of a given channel
 Vector readChannels(CmsObject cms, CmsMasterContent content)
          Reads all channels from the database.
protected  void readLockstate(CmsMasterDataSet dataset, int subId)
          Read the lockstate from the database.
 Vector readMedia(CmsObject cms, CmsMasterContent content)
          Reads all media from the database.
 void restore(CmsObject cms, CmsMasterContent content, CmsMasterDataSet dataset, int versionId)
          Restores a version of the master and media from backup
 void setRootChannel(String newRootChannel)
          Set the root channel
protected  void sqlClose(Connection con, Statement stmnt, ResultSet res)
          Closes all sql ressources.
protected  int sqlFillValues(PreparedStatement stmnt, CmsMasterMedia media)
          Fills a prepared statement with media values.
protected  int sqlFillValues(PreparedStatement stmnt, int subId, CmsMasterDataSet dataset)
          Inserts all values to the statement for insert and update.
protected  int sqlFillValues(ResultSet res, CmsObject cms, CmsMasterDataSet dataset)
          Inserts all values to the statement for insert and update.
protected  PreparedStatement sqlPrepare(CmsObject cms, Connection con, String queryKey)
          Creates a new connection and prepares a stement.
protected  PreparedStatement sqlPrepare(CmsObject cms, Connection con, String queryKey, HashMap optionalSqlTokens)
          Replaces in a SQL statement $XXX tokens by strings and returns a prepared statement.
protected  PreparedStatement sqlPrepare(Connection con, String queryKey)
          Creates a new connection and prepares a stement.
protected  int sqlSetDateArray(PreparedStatement stmnt, long[] array, int columnscounter)
          Sets an array of ints into the stmnt.
protected  int sqlSetDateArray(ResultSet res, long[] array, int columnscounter)
          Sets an array of ints from the resultset.
protected  int sqlSetIntArray(PreparedStatement stmnt, int[] array, int columnscounter)
          Sets an array of ints into the stmnt.
protected  int sqlSetIntArray(ResultSet res, int[] array, int columnscounter)
          Sets an array of ints from the resultset.
protected  int sqlSetTextArray(PreparedStatement stmnt, String[] array, int columnscounter)
          Sets an array of strings into the stmnt.
protected  int sqlSetTextArray(ResultSet res, String[] array, int columnscounter)
          Sets an array of strings from the resultset.
 String toString()
          Returns a string representation of this instance.
 void undelete(CmsObject cms, CmsMasterContent content, CmsMasterDataSet dataset)
           
protected  void updateChannels(CmsObject cms, int masterId, Vector channelToAdd, Vector channelToDelete)
          Updates the channels of a content definition.
protected  void updateMedia(int masterId, Vector mediaToAdd, Vector mediaToUpdate, Vector mediaToDelete)
          Updates the media object of a content definition.
 void write(CmsObject cms, CmsMasterContent content, CmsMasterDataSet dataset)
           
 void writeLockstate(CmsObject cms, CmsMasterContent content, CmsMasterDataSet dataset)
          Updates the lockstate in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

C_COS_PREFIX

public static final String C_COS_PREFIX
See Also:
Constant Field Values

m_poolName

protected String m_poolName
The pool to access offline ressources


m_onlinePoolName

protected String m_onlinePoolName
The pool to access the online ressources


m_backupPoolName

protected String m_backupPoolName
The pool to access the backup ressources


m_queries

protected Properties m_queries
The query properties for this accessmodule


m_rootChannel

protected String m_rootChannel
The root channel of the module

Constructor Detail

CmsDbAccess

public CmsDbAccess()
Public empty constructor, call "init()" on this class afterwards. This allows more flexible custom module development. FLEX: Made the constructor public!


CmsDbAccess

public CmsDbAccess(String poolName,
                   String onlinePoolName,
                   String backupPoolName)
Constructs a new DbAccessObject.

Parameters:
poolName - the pool to access offline ressources.
onlinePoolName - the pool to access the online ressources.
backupPoolName - the pool to access the backup ressources.
Method Detail

init

public void init(String offline,
                 String online,
                 String backup)
Initializes the DBAccessObject.


setRootChannel

public void setRootChannel(String newRootChannel)
Set the root channel

Parameters:
newRootChannel - the new value for the rootChannel

getRootChannel

public String getRootChannel()
Get the root channel


insert

public void insert(CmsObject cms,
                   CmsMasterContent content,
                   CmsMasterDataSet dataset)
            throws CmsException
Inserts a new row in the database with the dataset.

Parameters:
cms - the CmsObject to get access to cms-ressources.
content - the CmsMasterContent to write to the database.
dataset - the set of data for this contentdefinition.
CmsException

copy

public int copy(CmsObject cms,
                CmsMasterContent content,
                CmsMasterDataSet dataset,
                Vector mediaToAdd,
                Vector channelToAdd)
         throws CmsException
Inserts a new row in the database with the copied dataset.

Parameters:
cms - the CmsObject to get access to cms-ressources.
content - the CmsMasterContent to write to the database.
dataset - the set of data for this contentdefinition.
mediaToAdd - a Vector of media to add.
channelToAdd - a Vector of channels to add.
Returns:
int The id of the new content definition
CmsException

writeLockstate

public void writeLockstate(CmsObject cms,
                           CmsMasterContent content,
                           CmsMasterDataSet dataset)
                    throws CmsException
Updates the lockstate in the database.

Parameters:
cms - the CmsObject to get access to cms-ressources.
content - the CmsMasterContent to write to the database.
dataset - the set of data for this contentdefinition.
CmsException

write

public void write(CmsObject cms,
                  CmsMasterContent content,
                  CmsMasterDataSet dataset)
           throws CmsException
Parameters:
cms - the CmsObject to get access to cms-ressources.
content - the CmsMasterContent to write to the database.
dataset - the set of data for this contentdefinition.
CmsException

read

public void read(CmsObject cms,
                 CmsMasterContent content,
                 CmsMasterDataSet dataset,
                 int masterId)
          throws CmsException
Parameters:
cms - the CmsObject to get access to cms-ressources.
content - the CmsMasterContent to write to the database.
dataset - the set of data for this contentdefinition.
CmsException

readLockstate

protected void readLockstate(CmsMasterDataSet dataset,
                             int subId)
                      throws CmsException
Read the lockstate from the database. We nned this, because of someone has maybe stolen the lock.

Parameters:
dataset - the dataset to read the lockstate into.
subId - the subId of this cd
CmsException

readMedia

public Vector readMedia(CmsObject cms,
                        CmsMasterContent content)
                 throws CmsException
Reads all media from the database.

Parameters:
cms - the CmsObject to get access to cms-ressources.
content - the CmsMasterContent to write to the database.
Returns:
a Vector of media objects.
CmsException

readChannels

public Vector readChannels(CmsObject cms,
                           CmsMasterContent content)
                    throws CmsException
Reads all channels from the database.

Parameters:
cms - the CmsObject to get access to cms-ressources.
content - the CmsMasterContent to write to the database.
Returns:
a Vector of channel names.
CmsException

readAllByChannel

public Vector readAllByChannel(CmsObject cms,
                               int channelId,
                               int subId)
                        throws CmsException
Reads all content definitions of a given channel

Parameters:
cms - the CmsObject to get access to cms-ressources.
channelId - the id of the channel.
Returns:
Vector The datasets of the contentdefinitions in the channel
CmsException

delete

public void delete(CmsObject cms,
                   CmsMasterContent content,
                   CmsMasterDataSet dataset)
            throws CmsException
Parameters:
cms - the CmsObject to get access to cms-ressources.
content - the CmsMasterContent to write to the database.
dataset - the set of data for this contentdefinition.
CmsException

undelete

public void undelete(CmsObject cms,
                     CmsMasterContent content,
                     CmsMasterDataSet dataset)
              throws CmsException
Parameters:
cms - the CmsObject to get access to cms-ressources.
content - the CmsMasterContent to write to the database.
dataset - the set of data for this contentdefinition.
CmsException

changePermissions

public void changePermissions(CmsObject cms,
                              CmsMasterContent content,
                              CmsMasterDataSet dataset)
                       throws CmsException
Changes the perrmissions of the Master

Parameters:
cms - the CmsObject to get access to cms-ressources.
content - the CmsMasterContent to write to the database.
dataset - the set of data for this contentdefinition.
CmsException

toString

public String toString()
Returns a string representation of this instance. This can be used for debugging.

Overrides:
toString in class Object
Returns:
the string representation of this instance.

sqlPrepare

protected PreparedStatement sqlPrepare(Connection con,
                                       String queryKey)
                                throws SQLException
Creates a new connection and prepares a stement.

Parameters:
con - the Connection to use.
queryKey - the key for the query to use. The query will be get by m_queries.getParameter(key)
SQLException

sqlPrepare

protected PreparedStatement sqlPrepare(CmsObject cms,
                                       Connection con,
                                       String queryKey)
                                throws SQLException
Creates a new connection and prepares a stement.

Parameters:
cms - the CmsObject to get access to cms-ressources.
con - the Connection to use.
queryKey - the key for the query to use. The query will be get by m_queries.getParameter(key)
SQLException

sqlPrepare

protected PreparedStatement sqlPrepare(CmsObject cms,
                                       Connection con,
                                       String queryKey,
                                       HashMap optionalSqlTokens)
                                throws SQLException
Replaces in a SQL statement $XXX tokens by strings and returns a prepared statement.

Parameters:
cms - the current user's CmsObject instance
con - the JDBC connection
queryKey - the name of the SQL statement (in query.properties)
optionalSqlTokens - a HashMap with optional SQL tokens to be replaced in the SQL statement
Returns:
a new PreparedStatement
Throws:
SQLException

sqlClose

protected void sqlClose(Connection con,
                        Statement stmnt,
                        ResultSet res)
Closes all sql ressources.

Parameters:
con - the Connection to close.
stmnt - the SqlStatement to close.

sqlFillValues

protected int sqlFillValues(PreparedStatement stmnt,
                            int subId,
                            CmsMasterDataSet dataset)
                     throws SQLException
Inserts all values to the statement for insert and update.

Parameters:
stmnt - the Statement to fill the values to.
subId - the subid of this module.
dataset - the set of data for this contentdefinition.
Returns:
the actual rowcounter.
SQLException

sqlFillValues

protected int sqlFillValues(ResultSet res,
                            CmsObject cms,
                            CmsMasterDataSet dataset)
                     throws SQLException
Inserts all values to the statement for insert and update.

Parameters:
res - the Resultset read the values from.
cms - the CmsObject to get access to cms-ressources.
dataset - the set of data for this contentdefinition.
Returns:
the actual rowcounter.
SQLException

computeProjectId

protected int computeProjectId(CmsObject cms,
                               CmsMasterDataSet dataset)
                        throws SQLException
Computes the correct project id based on the channels.

SQLException

sqlSetTextArray

protected int sqlSetTextArray(PreparedStatement stmnt,
                              String[] array,
                              int columnscounter)
                       throws SQLException
Sets an array of strings into the stmnt.

Parameters:
stmnt - the PreparedStatement to set the values into.
array - the array of strings to set.
Returns:
the increased columnscounter;
SQLException

sqlSetTextArray

protected int sqlSetTextArray(ResultSet res,
                              String[] array,
                              int columnscounter)
                       throws SQLException
Sets an array of strings from the resultset.

Parameters:
res - the ResultSet to get the values from.
array - the array of strings to set.
Returns:
the increased columnscounter;
SQLException

sqlSetIntArray

protected int sqlSetIntArray(PreparedStatement stmnt,
                             int[] array,
                             int columnscounter)
                      throws SQLException
Sets an array of ints into the stmnt.

Parameters:
stmnt - the PreparedStatement to set the values into.
array - the array of ints to set.
Returns:
the increased columnscounter;
SQLException

sqlSetIntArray

protected int sqlSetIntArray(ResultSet res,
                             int[] array,
                             int columnscounter)
                      throws SQLException
Sets an array of ints from the resultset.

Parameters:
res - the ResultSet to get the values from.
array - the array of ints to set.
Returns:
the increased columnscounter;
SQLException

sqlSetDateArray

protected int sqlSetDateArray(PreparedStatement stmnt,
                              long[] array,
                              int columnscounter)
                       throws SQLException
Sets an array of ints into the stmnt.

Parameters:
stmnt - the PreparedStatement to set the values into.
array - the array of longs to set.
Returns:
the increased columnscounter;
SQLException

sqlSetDateArray

protected int sqlSetDateArray(ResultSet res,
                              long[] array,
                              int columnscounter)
                       throws SQLException
Sets an array of ints from the resultset.

Parameters:
res - the ResultSet to get the values from.
array - the array of longs to set.
Returns:
the increased columnscounter;
SQLException

createVectorOfCd

protected Vector createVectorOfCd(ResultSet res,
                                  Class contentDefinitionClass,
                                  CmsObject cms)
                           throws SQLException
Returns a vector of contentdefinitions based on the sql resultset. Never mind about the visible flag.

Parameters:
res - - the ResultSet to get data-lines from.
contentDefinitionClass - - the class of the cd to create new instances.
cms - - the CmsObject to get access to cms-ressources.
Throws:
SqlException - if nothing could be read from the resultset.
SQLException

createVectorOfCd

protected Vector createVectorOfCd(ResultSet res,
                                  Class contentDefinitionClass,
                                  CmsObject cms,
                                  boolean viewonly)
                           throws SQLException
Returns a vector of contentdefinitions based on the sql resultset.

Parameters:
res - - the ResultSet to get data-lines from.
contentDefinitionClass - - the class of the cd to create new instances.
cms - - the CmsObject to get access to cms-ressources.
viewonly - - decides, if only the ones that are visible should be returned
Throws:
SqlException - if nothing could be read from the resultset.
SQLException

createVectorOfCd

protected Vector createVectorOfCd(Vector datasets,
                                  Class contentDefinitionClass,
                                  CmsObject cms)
                           throws SQLException
Returns a vector of contentdefinitions based on the sql resultset.

Parameters:
datasets - - the vector with the datasets.
contentDefinitionClass - - the class of the cd to create new instances.
cms - - the CmsObject to get access to cms-ressources.
Throws:
SqlException - if nothing could be read from the resultset.
SQLException

checkAccess

protected boolean checkAccess(CmsMasterContent content,
                              boolean viewonly)
Checks if read (and visible) permissions are granted. the visible-permissens will be checked, if viewonly is set to true viewonly=true is needed for the backoffice

Parameters:
content - - the cd to check.
viewonly - - if set to true the v-Flag will be checked, too

isOnlineProject

protected boolean isOnlineProject(CmsObject cms)
Returns true, if this is the onlineproject

Parameters:
cms - - the CmsObject to get access to cms-ressources.
Returns:
true, if this is the onlineproject, else returns false

deleteAllMedia

protected void deleteAllMedia(int masterId)
                       throws SQLException
Deletes all media lines for one master.

Parameters:
masterId - - the masterId to delete the media for
Throws:
SQLException - if an sql-error occur

deleteAllChannels

protected void deleteAllChannels(int masterId)
                          throws SQLException
Deletes all channel lines for one master.

Parameters:
masterId - - the masterId to delete the media for
Throws:
SQLException - if an sql-error occur

updateMedia

protected void updateMedia(int masterId,
                           Vector mediaToAdd,
                           Vector mediaToUpdate,
                           Vector mediaToDelete)
                    throws SQLException,
                           CmsException
Updates the media object of a content definition.

Parameters:
masterId - the content definition master id
mediaToAdd - vector of media objects to add
mediaToUpdate - vector of media objects to update
mediaToDelete - vector of media objects to delete
Throws:
SQLException
CmsException

updateChannels

protected void updateChannels(CmsObject cms,
                              int masterId,
                              Vector channelToAdd,
                              Vector channelToDelete)
                       throws SQLException
Updates the channels of a content definition.

Parameters:
cms - the current context object
masterId - the content definition master id
channelToAdd - vector of channels to add
channelToDelete - vector of channels to delete
Throws:
SQLException

sqlFillValues

protected int sqlFillValues(PreparedStatement stmnt,
                            CmsMasterMedia media)
                     throws SQLException
Fills a prepared statement with media values.

Parameters:
stmnt - the statement to fill
media - the data to fill the statement with
Returns:
int the number of values set in the statement
Throws:
SQLException - if data could not be set in statement

getHistory

public Vector getHistory(CmsObject cms,
                         Class contentDefinitionClass,
                         int masterId,
                         int subId)
                  throws CmsException
Returns a vector with all version of a master in the backup

Parameters:
cms - The CmsObject
masterId - The id of the master
subId - The sub_id
Returns:
Vector A vector with all versions of the master
CmsException

getVersionFromHistory

public CmsMasterContent getVersionFromHistory(CmsObject cms,
                                              Class contentDefinitionClass,
                                              int masterId,
                                              int subId,
                                              int versionId)
                                       throws CmsException
Returns the version of a master in the backup

Parameters:
cms - The CmsObject
contentDefinitionClass - The class of the content definition
masterId - The id of the master
subId - The sub_id
versionId - The version id
Returns:
CmsMasterContent A content definition of the version
CmsException

getVersionFromHistory

public CmsMasterDataSet getVersionFromHistory(CmsObject cms,
                                              int masterId,
                                              int subId,
                                              int versionId)
                                       throws CmsException
Returns the version of a master in the backup

Parameters:
cms - The CmsObject
masterId - The id of the master
subId - The sub_id
versionId - The version id
Returns:
Vector A vector with all versions of the master
CmsException

restore

public void restore(CmsObject cms,
                    CmsMasterContent content,
                    CmsMasterDataSet dataset,
                    int versionId)
             throws CmsException
Restores a version of the master and media from backup

Parameters:
cms - The CmsObject
content - The master content
dataset - The dataset of the master
versionId - The version id of the master and media to restore
CmsException

publishResource

public void publishResource(CmsObject cms,
                            CmsMasterDataSet dataset,
                            int subId,
                            String contentDefinitionName,
                            boolean enableHistory,
                            int versionId,
                            long publishingDate,
                            Vector changedResources,
                            Vector changedModuleData)
                     throws CmsException
Publishes a single content definition

Parameters:
cms - The CmsObject
dataset - the dataset to publish.
subId - the subId to publish cd's for.
contentDefinitionName - the name of the contentdefinition.
enableHistory - set to true if backup tables should be filled.
versionId - the versionId to save in the backup tables.
publishingDate - the date and time of this publishing process.
CmsException

publishProject

public void publishProject(CmsObject cms,
                           boolean enableHistory,
                           int projectId,
                           int versionId,
                           long publishingDate,
                           int subId,
                           String contentDefinitionName,
                           Vector changedRessources,
                           Vector changedModuleData)
                    throws CmsException
Publishes all ressources for this project Publishes all modified content definitions for this project.

Parameters:
cms - The CmsObject
enableHistory - set to true if backup tables should be filled.
projectId - the Project that should be published.
versionId - the versionId to save in the backup tables.
publishingDate - the date and time of this publishing process.
subId - the subId to publish cd's for.
contentDefinitionName - the name of the contentdefinition.
changedRessources - a Vector of Ressources that were changed by this publishing process.
changedModuleData - a Vector of Ressource that were changed by this publishing process. New published data will be add to this Vector to return it.
CmsException

publishOneLine

protected void publishOneLine(CmsObject cms,
                              CmsMasterDataSet dataset,
                              int subId,
                              String contentDefinitionName,
                              boolean enableHistory,
                              int versionId,
                              long publishingDate,
                              Vector changedRessources,
                              Vector changedModuleData)
                       throws CmsException
Parameters:
cms - The CmsObject
dataset - the dataset to publish.
subId - the subId to publish cd's for.
contentDefinitionName - the name of the contentdefinition.
enableHistory - set to true if backup tables should be filled.
versionId - the versionId to save in the backup tables.
publishingDate - the date and time of this publishing process.
changedRessources - a Vector of Ressources that were changed by this publishing process.
changedModuleData - a Vector of Ressource that were changed by this publishing process. New published data will be add to this Vector to return it.
CmsException

publishDeleteData

protected void publishDeleteData(int masterId,
                                 int subId,
                                 String table)
                          throws CmsException
CmsException

publishCopyData

protected void publishCopyData(CmsMasterDataSet dataset,
                               int subId)
                        throws CmsException
CmsException

publishBackupData

protected void publishBackupData(CmsObject cms,
                                 CmsMasterDataSet dataset,
                                 int subId,
                                 int versionId,
                                 long publishDate)
                          throws CmsException
CmsException

getConnection

public Connection getConnection(CmsObject cms)
                         throws SQLException
Returns the correct connection. If this is the onlineproject it returns the online connection, else it returns the offline connection.

Parameters:
cms - the CmsObject to get access to cms-ressources.
Returns:
the SQLConnection.
Throws:
SQLException - if the connection can not be returned.