server
Class DbUtilities

java.lang.Object
  extended byserver.DbUtilities

public class DbUtilities
extends java.lang.Object


Constructor Summary
DbUtilities()
           
 
Method Summary
static void dbClose(java.sql.Connection dbConn)
          Close the connection to the database.
static java.sql.Connection dbConnection(Conf config)
          Establishes a database connection to a specific database.
static boolean dbIsAlive(java.sql.Connection dbConn)
          Test the database connection for viability.
static boolean executeUpdate(java.sql.Connection dbConn, java.lang.String update)
          Submit an update to the database, including INSERT and UPDATE statements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbUtilities

public DbUtilities()
Method Detail

dbConnection

public static java.sql.Connection dbConnection(Conf config)
                                        throws java.lang.Exception
Establishes a database connection to a specific database. Forms the connection by first registering the JDBC driver for the MySQL database server, then creating the connection to the database specified in the class data members.

Since constructors cannot return values, this constructor throws an Exception if the connection to the ddatabase fails. This allows the caller to handle the failure.

Parameters:
config - Configuration information about the database
Returns:
Connection to the database
Throws:
java.lang.Exception

dbClose

public static void dbClose(java.sql.Connection dbConn)
Close the connection to the database.

Parameters:
dbConn - Connection to the database

dbIsAlive

public static boolean dbIsAlive(java.sql.Connection dbConn)
Test the database connection for viability. If the connection still exists and the database responds, return true to the caller. If the database server fails to respond to a request, close the connection and return false to the caller.

Parameters:
dbConn - Connection to the database
Returns:
Boolean value indicating whether or not the database is still alive

executeUpdate

public static boolean executeUpdate(java.sql.Connection dbConn,
                                    java.lang.String update)
Submit an update to the database, including INSERT and UPDATE statements. Passed the supplied SQL string containing the INSERT or UPDATE to the database and return a boolean indicating success or failure.

Parameters:
dbConn - Connection to the database
update - String containing the INSERT or UPDATE SQL statement
Returns:
Boolean indicating the success of the update