de.janicke.hj.tools.servlet
Class Database

java.lang.Object
  |
  +--de.janicke.hj.tools.servlet.Database

public class Database
extends java.lang.Object

Class handles the database connection. There is functionality to precompile SQL statements.
jdbc stands for JavaDataBaseConnection.


Field Summary
 java.sql.Connection jdbc
          DB-Connection
 
Constructor Summary
Database()
           
Database(java.lang.String jdbcDriver, java.lang.String jdbcConnection)
          Constructs a new Database object.
 
Method Summary
 boolean close()
          Closes the database connection.
 void commitData()
          Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection.
 boolean isOpened()
          Returns true if connection established.
 boolean open()
          Opens the database specified by the jdbcConnection value.
 java.sql.PreparedStatement precompile(java.lang.String sqlStatement)
          Precompiles a SQL statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jdbc

public java.sql.Connection jdbc
DB-Connection
Constructor Detail

Database

public Database(java.lang.String jdbcDriver,
                java.lang.String jdbcConnection)
Constructs a new Database object.
Parameters:
jdbcDriver - String that identifies the driver class.
jdbcConnection - String that identifies the database connection.

Database

public Database()
Method Detail

open

public boolean open()
Opens the database specified by the jdbcConnection value. Checks also for existance of the driver class specified by jdbcDriver.
Returns:
true if succeded, false otherwise.

commitData

public void commitData()
Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection.

close

public boolean close()
Closes the database connection.
Returns:
true if succeded, false otherwise.

isOpened

public boolean isOpened()
Returns true if connection established.
Returns:
true if opened.

precompile

public java.sql.PreparedStatement precompile(java.lang.String sqlStatement)
                                      throws java.sql.SQLException
Precompiles a SQL statement.
Parameters:
sqlStatement - The SQL statement to compile.
Returns:
The precompiled SQL statement, or null if the connection is closed.