net.sf.borg.model.db.jdbc
Class JdbcDB

java.lang.Object
  extended by net.sf.borg.model.db.jdbc.JdbcDB
Direct Known Subclasses:
JdbcBeanDB, MemoJdbcDB

public abstract class JdbcDB
extends Object

abstract base class providing basic common JDBC services to all derived JDBC classes


Field Summary
protected static Connection connection_
           
 
Constructor Summary
JdbcDB()
           
 
Method Summary
static void beginTransaction()
          begin a JDBC transaction on the shared connection
static String buildDbDir()
          Builds the db url from the user's settings.
static void close()
          Close the open connection and shutdown the db (if HSQL)
static void commitTransaction()
          commit a JDBC transaction on the shared connection
static void connect(String urlIn)
          Connect to the database.
static ResultSet execSQL(String sql)
          Execute arbitrary SQL against the open JDBC connection
static Connection getConnection()
          Gets the connection.
static String getOption(String oname)
          Gets an option value from the options table
static Collection<BorgOption> getOptions()
          Gets all options from the options table.
static String getUrl()
          Gets the JDBC url.
static void rollbackTransaction()
          rollback a JDBC transaction on the shared connection
static void setOption(BorgOption option)
          Sets an option in the options table.
protected static int toInt(boolean in)
           
protected static int toInt(Integer in)
           
protected static String toStr(Vector<String> v)
           
protected static Vector<String> toVect(String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connection_

protected static Connection connection_
Constructor Detail

JdbcDB

public JdbcDB()
Method Detail

getUrl

public static String getUrl()
Gets the JDBC url.

Returns:
the JDBC url

beginTransaction

public static void beginTransaction()
                             throws Exception
begin a JDBC transaction on the shared connection

Throws:
Exception

commitTransaction

public static final void commitTransaction()
                                    throws Exception
commit a JDBC transaction on the shared connection

Throws:
Exception

rollbackTransaction

public static final void rollbackTransaction()
                                      throws Exception
rollback a JDBC transaction on the shared connection

Throws:
Exception

connect

public static void connect(String urlIn)
                    throws Exception
Connect to the database. The logic varies based on the URL. Supports MYSQL, HSQL For HSQL - if the DB doesn't exist, it will be created

Parameters:
urlIn - the JDBC url
Throws:
Exception - the exception

toStr

protected static final String toStr(Vector<String> v)

toInt

protected static final int toInt(Integer in)

toInt

protected static final int toInt(boolean in)

toVect

protected static final Vector<String> toVect(String s)

execSQL

public static final ResultSet execSQL(String sql)
                               throws Exception
Execute arbitrary SQL against the open JDBC connection

Parameters:
sql - the sql
Returns:
the result set
Throws:
Exception - the exception

getConnection

public static Connection getConnection()
Gets the connection.

Returns:
the connection

close

public static void close()
                  throws Exception
Close the open connection and shutdown the db (if HSQL)

Throws:
Exception - the exception

getOption

public static final String getOption(String oname)
                              throws Exception
Gets an option value from the options table

Parameters:
oname - the option name
Returns:
the option value
Throws:
Exception - the exception

getOptions

public static final Collection<BorgOption> getOptions()
                                               throws Exception
Gets all options from the options table.

Returns:
a collection of options
Throws:
Exception - the exception

setOption

public static final void setOption(BorgOption option)
                            throws Exception
Sets an option in the options table.

Parameters:
option - the option to set
Throws:
Exception - the exception

buildDbDir

public static String buildDbDir()
Builds the db url from the user's settings. Supports HSQL, MYSQL, generic JDBC

Returns:
the jdbc url


Generated September 24 2010 by mbb using Apache Ant version 1.7.1 compiled on June 27 2008 and Java version 1.6.0_20 from Sun Microsystems Inc. on Linux i386 2.6.24-28-generic