com.exponto.jstock
Class DBManager

java.lang.Object
  |
  +--com.exponto.jstock.DBManager

public class DBManager
extends java.lang.Object

A manager class for the database. Handles opening and closing of connections and simple updates and inserts. This is a singleton.

Author:
kaare

Method Summary
 void closeConnection()
          Closes the db connection
static int executeUpdate(java.lang.String sql)
          Executes simple updates or inserts.
 java.sql.Connection getConnection()
          Use this to get a db connection.
static DBManager getInstance()
          Use this one to get an instance of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DBManager getInstance()
Use this one to get an instance of this class. Will create one if it doesn't exist.

Returns:
the instance of the class

getConnection

public java.sql.Connection getConnection()
Use this to get a db connection. Logfile is updated in case of error.

Returns:
a db Connection if successful, otherwise null.

closeConnection

public void closeConnection()
Closes the db connection


executeUpdate

public static int executeUpdate(java.lang.String sql)
Executes simple updates or inserts. In case of error, 0 is returned and additional information is in the logfile.

Parameters:
sql - - the complete sql statement that is to be executed.
Returns:
the number of rows that was affected by the update


Copyright © 2004 Kaare Ranum