ZetaGrid v1.9

zeta.util
Class DatabaseUtils

java.lang.Object
  |
  +--zeta.util.DatabaseUtils

public class DatabaseUtils
extends java.lang.Object

Provides database utilities especially for the servlets.


Field Summary
private static long DB2_DAYS_MILLIS_DIFF
           
private static int numberOfServers
           
 
Constructor Summary
DatabaseUtils()
           
 
Method Summary
static void close(java.sql.Connection con)
          Releases a connection's database and JDBC resources immediately instead of waiting for them to be automatically released.
static void close(java.sql.Statement stmt)
          Releases a statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.
static long convertDaysToTimeMillis(long days)
          Converts days to time millis.
static long convertTimeMillisToDays(long timeMillis)
          Converts days to time millis.
static void db2CLP(java.lang.String db2)
          Executes the Command Line Processor.
static java.lang.String encodeName(java.lang.String name)
          Encodes a name so that it can be stored in the database.
static void executeAndLogUpdate(int serverId, java.sql.Statement stmt, java.lang.String sqlStatement)
          Executing and logging a SQL statement in the database to synchronize different servers.
static void executeAndLogUpdate(ZetaServlet servlet, java.lang.String sqlStatement)
          Executing and logging a SQL statement in the database to synchronize different servers.
private static java.lang.String getLogStatement(int serverId, java.sql.Statement stmt, java.lang.String sqlStatement, java.lang.StringBuffer buffer)
          Generates logging statements.
static java.lang.String log(int serverId, java.sql.Statement stmt, java.lang.String sqlStatement)
          Logging SQL statements in the database to synchronize different servers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numberOfServers

private static int numberOfServers

DB2_DAYS_MILLIS_DIFF

private static final long DB2_DAYS_MILLIS_DIFF
See Also:
Constant Field Values
Constructor Detail

DatabaseUtils

public DatabaseUtils()
Method Detail

close

public static void close(java.sql.Connection con)
Releases a connection's database and JDBC resources immediately instead of waiting for them to be automatically released. No exception will be thrown if a database access error occurs.

Parameters:
con - the connection to the database

close

public static void close(java.sql.Statement stmt)
Releases a statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed. No exception will be thrown if a database access error occurs.

Parameters:
stmt - statement object's database

log

public static java.lang.String log(int serverId,
                                   java.sql.Statement stmt,
                                   java.lang.String sqlStatement)
                            throws java.sql.SQLException
Logging SQL statements in the database to synchronize different servers.

Parameters:
serverId - ID of the server
stmt - statement object's database
sqlStatement - SQL statement which should be logged
Returns:
the SQL statement where 'CURRENT TIMESTAMP' is replaced by the current timestamp if the synchronization is activated.
Throws:
java.sql.SQLException - if a database access error occurs.

executeAndLogUpdate

public static void executeAndLogUpdate(ZetaServlet servlet,
                                       java.lang.String sqlStatement)
                                throws java.sql.SQLException,
                                       javax.servlet.ServletException
Executing and logging a SQL statement in the database to synchronize different servers.

Parameters:
servlet - servlet which has a connection to the server database.
sqlStatement - SQL statement which should be logged
Throws:
java.sql.SQLException - if a database access error occurs.
javax.servlet.ServletException

executeAndLogUpdate

public static void executeAndLogUpdate(int serverId,
                                       java.sql.Statement stmt,
                                       java.lang.String sqlStatement)
                                throws java.sql.SQLException
Executing and logging a SQL statement in the database to synchronize different servers.

Parameters:
serverId - ID of the server
stmt - statement object's database
sqlStatement - SQL statement which should be logged
Throws:
java.sql.SQLException - if a database access error occurs.

encodeName

public static java.lang.String encodeName(java.lang.String name)
Encodes a name so that it can be stored in the database.

Parameters:
name - name to be encoded
Returns:
encoded name

db2CLP

public static void db2CLP(java.lang.String db2)
                   throws java.io.IOException
Executes the Command Line Processor.

Parameters:
db2 - DB2 commands which will be sent to the Command Line Processor.
java.io.IOException

convertDaysToTimeMillis

public static long convertDaysToTimeMillis(long days)
Converts days to time millis.

Parameters:
days - days
Returns:
converted days to time millis.

convertTimeMillisToDays

public static long convertTimeMillisToDays(long timeMillis)
Converts days to time millis.

Returns:
converted days to time millis.

getLogStatement

private static java.lang.String getLogStatement(int serverId,
                                                java.sql.Statement stmt,
                                                java.lang.String sqlStatement,
                                                java.lang.StringBuffer buffer)
Generates logging statements.

Parameters:
serverId - ID of the server
stmt - statement object's database
sqlStatement - SQL statement which should be logged
Returns:
the SQL statement where 'CURRENT TIMESTAMP' is replaced by the current timestamp.

ZetaGrid v1.9

For further technical papers, see ZetaGrid Technical Documentation.
 
Copyright © 2001,2002 Sebastian Wedeniwski. All Rights Reserved.