com.lightdev.app.trec.server
Class SQLAdapter

java.lang.Object
  extended by com.lightdev.lib.sam.JDBCAdapter
      extended by com.lightdev.app.trec.server.SQLAdapter

public class SQLAdapter
extends JDBCAdapter

JDBC adapter to connect to a database. This adapter assumes a file named 'db.properties' in the package this class resides in. In file 'db.properties' all relevant actual database settings such as driver, server or database name can be made. When this adapter is deployed on a server, file db.properties can be adjusted after deploment to connect to an individual database without having to recompile and redeploy this class.

Alternately settings can be made by calling methods setDriverName and setConnectString

Version:
2, 15.01.2006
Author:
Ulrich Hilger, Light Development, http://www.lightdev.com, info@lightdev.com, published under the terms and conditions of the BSD License, for details see file license.txt in the distribution package of this software

Field Summary
 
Fields inherited from class com.lightdev.lib.sam.JDBCAdapter
RB_KEY_DB_DRIVER_NAME, RB_KEY_DB_NAME, RB_KEY_DB_PREFIX, RB_KEY_DB_PW, RB_KEY_DB_SERVER_NAME, RB_KEY_DB_USER_NAME
 
Constructor Summary
SQLAdapter()
          create a new instance of an SQLAdapter object
 
Method Summary
 void destroy()
          destroy this adapter
 Connection getConnection()
          get a connection to the database this adapter refers to
 String getConnectString()
          get a string such as jdbc:mysql://server/database?
 void setConnectString(String connectString)
          set the connect string this adapter should use This method can be used as an alternative to using a 'db.properties' resource bundle
 void setDriverName(String driverName)
          set the name of the JDBC database driver class this adapter should use to connect to a database
 void setSupportsTransactions(boolean supportsTransactions)
          indicate whether of not the database this adapter refers to supports transactions
 boolean supportsTransactions()
          determine whether or not the database supports transactions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLAdapter

public SQLAdapter()
create a new instance of an SQLAdapter object

Method Detail

getConnection

public Connection getConnection()
                         throws Exception
get a connection to the database this adapter refers to

Specified by:
getConnection in class JDBCAdapter
Returns:
the connection or null of none could be obtained
Throws:
Exception

supportsTransactions

public boolean supportsTransactions()
determine whether or not the database supports transactions

Specified by:
supportsTransactions in class JDBCAdapter
Returns:
true when transactions are supported or false if not

setDriverName

public void setDriverName(String driverName)
set the name of the JDBC database driver class this adapter should use to connect to a database

Parameters:
driverName - name of driver class including full package name

setConnectString

public void setConnectString(String connectString)
set the connect string this adapter should use

This method can be used as an alternative to using a 'db.properties' resource bundle

Parameters:
connectString - the connect string to use

getConnectString

public String getConnectString()
get a string such as jdbc:mysql://server/database?user=name&password=pw

Specified by:
getConnectString in class JDBCAdapter

destroy

public void destroy()
destroy this adapter

Specified by:
destroy in class JDBCAdapter

setSupportsTransactions

public void setSupportsTransactions(boolean supportsTransactions)
indicate whether of not the database this adapter refers to supports transactions

Parameters:
supportsTransactions - true when transactions are supported, false if not