org.openbandy.io.storage
Class DatabaseConnection

java.lang.Object
  extended by org.openbandy.io.storage.DatabaseConnection
All Implemented Interfaces:
StorageConnection

public class DatabaseConnection
extends java.lang.Object
implements StorageConnection

The DatabaseConnection class implements the StorageConnection class in order to execute SQL statements on the JDBC database. To do so, it makes use of the java.sql package classes. Additionally, it features the getLastInsertedId() method, which returns the numeric ID value of the last object that was inserted into the database.

(c) Copyright Philipp Bolliger 2007, ALL RIGHTS RESERVED.

Version:
1.0
Author:
Philipp Bolliger (philipp@bolliger.name)

Method Summary
 void close()
          TODO comment!
 boolean connect()
          TODO comment!
 boolean executeDELETE(Serializable serializable)
          This method deletes the serializable object in the storage.
 int executeINSERT(ObjectEntry objectEntry)
          This method inserts the objectEntry in the database and returns the genereated id resp.
 java.sql.ResultSet executeSELECT(java.lang.String sql)
          This method returns the ResultSet for the select statement sql .
 void executeUPDATE(ObjectEntry objectEntry)
          This method updates the objectEntry in the database.
 java.lang.String getConnectionIdentifier()
          Returns a string that allows the Storage to distinguish different connections in order to avert muliple open connections for the same serializer.
 int getLastInsertedId(ObjectEntry entry)
           
static DatabaseConnection instance()
           
 boolean isConnected()
          TODO comment!
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instance

public static DatabaseConnection instance()

connect

public boolean connect()
Description copied from interface: StorageConnection
TODO comment!

Specified by:
connect in interface StorageConnection
Returns:

isConnected

public boolean isConnected()
Description copied from interface: StorageConnection
TODO comment!

Specified by:
isConnected in interface StorageConnection
Returns:

close

public void close()
Description copied from interface: StorageConnection
TODO comment!

Specified by:
close in interface StorageConnection

getConnectionIdentifier

public java.lang.String getConnectionIdentifier()
Description copied from interface: StorageConnection
Returns a string that allows the Storage to distinguish different connections in order to avert muliple open connections for the same serializer.

Specified by:
getConnectionIdentifier in interface StorageConnection
Returns:

executeINSERT

public int executeINSERT(ObjectEntry objectEntry)
This method inserts the objectEntry in the database and returns the genereated id resp. key.

Specified by:
executeINSERT in interface StorageConnection
Parameters:
objectEntry -
Returns:
newKey The key generated by the database while executing the INSERT.

executeUPDATE

public void executeUPDATE(ObjectEntry objectEntry)
This method updates the objectEntry in the database.

Specified by:
executeUPDATE in interface StorageConnection
Parameters:
objectEntry -

executeDELETE

public boolean executeDELETE(Serializable serializable)
Description copied from interface: StorageConnection
This method deletes the serializable object in the storage.

Specified by:
executeDELETE in interface StorageConnection
Parameters:
serializable - Entry to delete
Returns:
Returns true if the serializable object has been deleted.

executeSELECT

public java.sql.ResultSet executeSELECT(java.lang.String sql)
This method returns the ResultSet for the select statement sql . If the select statement sql produces no results, this method will return null . Otherwise, the cursor will be set to the first row.

Parameters:
sql - The select statement to be executed.
Returns:
resultSet

getLastInsertedId

public int getLastInsertedId(ObjectEntry entry)