org.opencms.db
Class CmsDbUtil

java.lang.Object
  extended byorg.opencms.db.CmsDbUtil

public final class CmsDbUtil
extends java.lang.Object

This class is used to create primary keys as integers for Cms database tables that don't have a UUID primary key.

Since:
6.0.0
Version:
$Revision: 1.25 $
Author:
Thomas Weckert, Carsten Weinholz

Field Summary
static int UNKNOWN_ID
          Indicates an unknown (or not set) id.
 
Method Summary
static java.sql.Timestamp getTimestamp(java.sql.ResultSet result, java.lang.String column)
          This method tries to get the timestamp several times, because there is a timing problem in the mysql driver.
static void init()
          Initilizes this DB utils.
static int nextId(java.lang.String tableName)
          Creates a new primary key ID for a given table.
static int nextId(java.lang.String dbPoolUrl, java.lang.String tableName)
          Creates a new primary key ID for a given table using JDBC connection specified by a pool URL.
static void setDefaultPool(java.lang.String dbPoolUrl)
          Sets the URL of the connection pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_ID

public static final int UNKNOWN_ID
Indicates an unknown (or not set) id.

See Also:
Constant Field Values
Method Detail

getTimestamp

public static java.sql.Timestamp getTimestamp(java.sql.ResultSet result,
                                              java.lang.String column)
                                       throws java.sql.SQLException
This method tries to get the timestamp several times, because there is a timing problem in the mysql driver.

Parameters:
result - the resultset to get the stamp from
column - the column to read the timestamp from
Returns:
the timestamp
Throws:
java.sql.SQLException - if something goes wrong

init

public static void init()
Initilizes this DB utils.


nextId

public static int nextId(java.lang.String tableName)
                  throws CmsException
Creates a new primary key ID for a given table.

Parameters:
tableName - the name of the table to create a new primary key ID
Returns:
a new primary key ID for the given table
Throws:
CmsException - if something goes wrong

nextId

public static int nextId(java.lang.String dbPoolUrl,
                         java.lang.String tableName)
                  throws CmsDataAccessException
Creates a new primary key ID for a given table using JDBC connection specified by a pool URL.

Parameters:
dbPoolUrl - the URL to access the connection pool
tableName - the name of the table to create a new primary key ID
Returns:
a new primary key ID for the given table
Throws:
CmsDataAccessException - if something goes wrong

setDefaultPool

public static void setDefaultPool(java.lang.String dbPoolUrl)
Sets the URL of the connection pool.

Parameters:
dbPoolUrl - the URL to access the connection pool