com.planet_ink.coffee_mud.core.database
Class DBConnector

java.lang.Object
  extended by com.planet_ink.coffee_mud.core.database.DBConnector

public class DBConnector
extends java.lang.Object


Constructor Summary
DBConnector()
           
DBConnector(java.lang.String NEWDBClass, java.lang.String NEWDBService, java.lang.String NEWDBUser, java.lang.String NEWDBPass, int NEWnumConnections, boolean NEWReuse, boolean NEWDoErrorQueueing)
           
 
Method Summary
 boolean amIOk()
          Return the happiness level of the connections

Usage: amIOk()
 void DBDone(DBConnection D)
          Return a DBConnection object fetched with DBFetch()

Usage:
 DBConnection DBFetch()
          Fetch a single, not in use DBConnection object.
 DBConnection DBFetchPrepared(java.lang.String SQL)
          Fetch a single, not in use DBConnection object.
 boolean deregisterDriver()
           
 void enQueueError(java.lang.String SQLString, java.lang.String SQLError, java.lang.String count)
          Queue up a failed write/update for later processing.
 java.lang.StringBuffer errorStatus()
          return a status string, or "" if everything is ok.
 long getLongRes(java.sql.ResultSet Results, java.lang.String Field)
          When reading a database table, this routine will read in the given Field NAME, returning the value.
 int getRecordCount(DBConnection D, java.sql.ResultSet R)
           
 java.lang.String getRes(java.sql.ResultSet Results, int One)
          When reading a database table, this routine will read in the given One index number, returning the value.
 java.lang.String getRes(java.sql.ResultSet Results, java.lang.String Field)
          When reading a database table, this routine will read in the given Field NAME, returning the value.
 java.lang.String getResQuietly(java.sql.ResultSet Results, java.lang.String Field)
           
 void killConnections()
          Destroy all database connections, effectively shutting down this class.
 void listConnections(java.io.PrintStream out)
          list the connections

Usage: listConnections(out);
 int numConnectionsMade()
           
 int numDBConnectionsInUse()
           
 int queryRows(java.lang.String queryString)
           
 void reconnect()
           
 void retryQueuedErrors()
          Queue up a failed write/update for later processing.
 java.lang.String service()
           
 int update(java.lang.String updateString)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBConnector

public DBConnector()

DBConnector

public DBConnector(java.lang.String NEWDBClass,
                   java.lang.String NEWDBService,
                   java.lang.String NEWDBUser,
                   java.lang.String NEWDBPass,
                   int NEWnumConnections,
                   boolean NEWReuse,
                   boolean NEWDoErrorQueueing)
Method Detail

reconnect

public void reconnect()

service

public java.lang.String service()

getRecordCount

public int getRecordCount(DBConnection D,
                          java.sql.ResultSet R)

deregisterDriver

public boolean deregisterDriver()

update

public int update(java.lang.String updateString)

queryRows

public int queryRows(java.lang.String queryString)

DBFetch

public DBConnection DBFetch()
Fetch a single, not in use DBConnection object. You can then call DBConnection.query and DBConnection.update on this object. The user must ALWAYS call DBDone when done with the object.

Usage: DB=DBFetch();

Returns:
DBConnection The DBConnection to use

numConnectionsMade

public int numConnectionsMade()

numDBConnectionsInUse

public int numDBConnectionsInUse()

DBFetchPrepared

public DBConnection DBFetchPrepared(java.lang.String SQL)
Fetch a single, not in use DBConnection object. You can then call DBConnection.query and DBConnection.update on this object. The user must ALWAYS call DBDone when done with the object.

Usage: DB=DBFetchPrepared();

Parameters:
SQL - The prepared statement SQL
Returns:
DBConnection The DBConnection to use

DBDone

public void DBDone(DBConnection D)
Return a DBConnection object fetched with DBFetch()

Usage:

Parameters:
D - The Database connection to return to the pool

getRes

public java.lang.String getRes(java.sql.ResultSet Results,
                               java.lang.String Field)
When reading a database table, this routine will read in the given Field NAME, returning the value. The value will be trim()ed, and will not be NULL.

Usage: str=getLongRes(R,"FIELD");

Parameters:
Results - The ResultSet object to use
Field - Field name to return
Returns:
String The value of the field being returned

getResQuietly

public java.lang.String getResQuietly(java.sql.ResultSet Results,
                                      java.lang.String Field)

getLongRes

public long getLongRes(java.sql.ResultSet Results,
                       java.lang.String Field)
When reading a database table, this routine will read in the given Field NAME, returning the value. The value will be trim()ed, and will not be NULL.

Usage: str=getLongRes(R,"FIELD");

Parameters:
Results - The ResultSet object to use
Field - Field name to return
Returns:
String The value of the field being returned

getRes

public java.lang.String getRes(java.sql.ResultSet Results,
                               int One)
When reading a database table, this routine will read in the given One index number, returning the value. The value will be trim()ed, and will not be NULL.

Usage: str=getRes(R,1);

Parameters:
Results - The ResultSet object to use
One - Field number to return
Returns:
String The value of the field being returned

killConnections

public void killConnections()
Destroy all database connections, effectively shutting down this class.

Usage: killConnections();


amIOk

public boolean amIOk()
Return the happiness level of the connections

Usage: amIOk()

Returns:
boolean true if ok, false if not ok

enQueueError

public void enQueueError(java.lang.String SQLString,
                         java.lang.String SQLError,
                         java.lang.String count)
Queue up a failed write/update for later processing.

Usage: enQueueError("UPDATE SQL","error string");

Parameters:
SQLString - UPDATE style SQL statement
SQLError - The error message being reported
count - The number of tries so far

retryQueuedErrors

public void retryQueuedErrors()
Queue up a failed write/update for later processing.

Usage: RetryQueuedErrors();


listConnections

public void listConnections(java.io.PrintStream out)
list the connections

Usage: listConnections(out);

Parameters:
out - place to send the list out to

errorStatus

public java.lang.StringBuffer errorStatus()
return a status string, or "" if everything is ok.

Usage: errorStatus();

Returns:
StringBuffer complete error status