org.pricingnexus.tools
Class DatabaseWrapper
java.lang.Object
|
+--org.pricingnexus.tools.DatabaseWrapper
- public class DatabaseWrapper
- extends java.lang.Object
This is a lightweigt database wrapper, created and used for the PricingNexus project
$Header$
Constructor Summary |
DatabaseWrapper(java.lang.String url,
java.lang.String className,
java.lang.String user,
java.lang.String password)
Default constructer. |
Method Summary |
void |
addBatch(java.lang.String sql)
Same as Statement.addBatch(String) |
void |
close()
Releases all open resources |
void |
connect()
Creates a jdbc-connection and stores it in wrapper instance |
java.sql.Statement |
createStatement()
Creates a statement and stores reference to it in wrapper instance |
int[] |
executeBatch()
Same as Statement.executeBatch(). |
java.sql.ResultSet |
executeQuery(java.lang.String sql)
Same as Statement.executeQuery(String). |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
Same as Connection.prepareStatment(sql) |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
dbConnection
public java.sql.Connection dbConnection
dbStatement
public java.sql.Statement dbStatement
dbPreparedStatement
public java.sql.PreparedStatement dbPreparedStatement
dbResultSet
public java.sql.ResultSet dbResultSet
DatabaseWrapper
public DatabaseWrapper(java.lang.String url,
java.lang.String className,
java.lang.String user,
java.lang.String password)
throws java.lang.ClassNotFoundException,
java.sql.SQLException
- Default constructer. Just sets connection specific parameters but does not connect.
- Parameters:
url
- Used for the jdbc-"connect()" method to connect to the databaseclassName
- Classname of the underlying driver class. Specific for each kind of database.user
- Username to connect withpassword
- Password to use for connection- Throws:
java.lang.ClassNotFoundException
- Thrown if jdbc-driver class not found in class path
connect
public void connect()
throws java.sql.SQLException
- Creates a jdbc-connection and stores it in wrapper instance
createStatement
public java.sql.Statement createStatement()
throws java.sql.SQLException
- Creates a statement and stores reference to it in wrapper instance
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
throws java.sql.SQLException
- Same as Connection.prepareStatment(sql)
executeQuery
public java.sql.ResultSet executeQuery(java.lang.String sql)
throws java.sql.SQLException
- Same as Statement.executeQuery(String). createStatement must haven been performend before to create a underlying statement.
- Parameters:
sql
- SQL-command to be performend. Must be a single "SELECT" statement, as it is expected to return a resultset.
addBatch
public void addBatch(java.lang.String sql)
throws java.sql.SQLException
- Same as Statement.addBatch(String)
executeBatch
public int[] executeBatch()
throws java.sql.SQLException
- Same as Statement.executeBatch().
close
public void close()
- Releases all open resources