org.jlab.coda.afecs.sqldb
Class DbConnection

java.lang.Object
  extended by org.jlab.coda.afecs.sqldb.DbConnection

public class DbConnection
extends java.lang.Object

JSA: Thomas Jefferson National Accelerator Facility
This software was developed under a United States Government license,
described in the NOTICE file included as part of this distribution.
Copyright (c), Aug 17, 2009


Method Summary
static void closeConnection()
          This method closes the database connection.
static boolean createConnection(java.lang.String _url, java.lang.String _driver, java.lang.String _user, java.lang.String _pswd)
          Create a connection to the database specified by the arguments.
static java.sql.Connection getConnection()
          This method returns the database connection object.
static boolean isConnected()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isConnected

public static boolean isConnected()
Returns:
true if there is a connection to the database

getConnection

public static java.sql.Connection getConnection()
This method returns the database connection object. There is only one such object - a singleton.

Returns:
Connection object

closeConnection

public static void closeConnection()
This method closes the database connection.


createConnection

public static boolean createConnection(java.lang.String _url,
                                       java.lang.String _driver,
                                       java.lang.String _user,
                                       java.lang.String _pswd)
                                throws AException
Create a connection to the database specified by the arguments. Only allow this method to be run if the single instance of the database connection has not been made yet. Once the connection is made, it can be closed and later recreated.

Parameters:
_url - URL for the database, i.e. jdbc:msql://mizar.jlab.org:8101/ghexp
_driver - jdbc driver suitable for associated URL, i.e. com.imaginary.sql.msql.MsqlDriver
_user - user name for the database, i.e. any string for msql
_pswd - password name for the database, i.e. blank string for msql
Returns:
true if a new connection to the database was successfully made, or false if the database connection already exists
Throws:
AException - object