org.javaWebGen.data
Class MySQLDataManager

java.lang.Object
  extended by org.javaWebGen.data.MySQLDataManager
All Implemented Interfaces:
DataManager

public class MySQLDataManager
extends java.lang.Object
implements DataManager

handles talking to an mySQL database. NOTE transactions may not do anything if the database was built with ISAM instead of INODB This is the MOST TESTED Datamanger because I have My SQL installed.


Field Summary
 java.lang.String BIG_DECIMAL
           
 java.lang.String DATE
           
 java.lang.String INT
           
 java.lang.String LONG
           
 java.lang.String OBJECT
           
 java.lang.String STRING
           
 java.lang.String TIMESTAMP
           
 
Constructor Summary
MySQLDataManager()
           
 
Method Summary
 void close(java.sql.Connection con)
          Return a connection back to the pool of available connections
 void endTransaction(java.sql.Connection con)
          commit transaction
 java.lang.String formatDate(java.util.Date date)
          get a String of a date object in the databases native format useful for doing updates etc..
 java.sql.Connection getConnection()
          get db connection
 java.util.Date getDate(java.lang.String dateStr)
          get a date object by parsing a string the databases native format useful for doing updates etc..
 int getNextValue(java.sql.Connection con, java.lang.String tablename)
          get next value for the primary key
 int getNextValue(java.lang.String tablename)
          get next value for the primary key
 Sequence getSequence()
           
 java.lang.String getSqlText(java.lang.String text)
          get a String that is escaped (handles ') mysql like \' not ''
 java.lang.String[] getTableList()
          get a list of tables from the system catalog
 void init()
           
 void rollbackTransaction(java.sql.Connection con)
          rollback transaction
 void setReader(PropertiesReader propReader)
          set db properties reader
 void setSequence(Sequence seq)
          Use this sequence generator NOTE this should not be used by a calling class
 void startTransaction(java.sql.Connection con)
          start a DB transaction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BIG_DECIMAL

public final java.lang.String BIG_DECIMAL
See Also:
Constant Field Values

LONG

public final java.lang.String LONG
See Also:
Constant Field Values

INT

public final java.lang.String INT
See Also:
Constant Field Values

STRING

public final java.lang.String STRING
See Also:
Constant Field Values

OBJECT

public final java.lang.String OBJECT
See Also:
Constant Field Values

DATE

public final java.lang.String DATE
See Also:
Constant Field Values

TIMESTAMP

public final java.lang.String TIMESTAMP
See Also:
Constant Field Values
Constructor Detail

MySQLDataManager

public MySQLDataManager()
Method Detail

setReader

public void setReader(PropertiesReader propReader)
set db properties reader

Specified by:
setReader in interface DataManager
Parameters:
propReader - base properties reader

setSequence

public void setSequence(Sequence seq)
Description copied from interface: DataManager
Use this sequence generator NOTE this should not be used by a calling class

Specified by:
setSequence in interface DataManager
Parameters:
seq - Sequence object

init

public void init()
Specified by:
init in interface DataManager

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Description copied from interface: DataManager
get db connection

Specified by:
getConnection in interface DataManager
Returns:
JDBC connection object
Throws:
java.sql.SQLException

close

public void close(java.sql.Connection con)
Return a connection back to the pool of available connections

Specified by:
close in interface DataManager
Parameters:
con - JDBC Connection object

getNextValue

public int getNextValue(java.lang.String tablename)
                 throws DBException
Description copied from interface: DataManager
get next value for the primary key

Specified by:
getNextValue in interface DataManager
Parameters:
tablename - table name to get next key for
Returns:
the next unique value
Throws:
DBException

getNextValue

public int getNextValue(java.sql.Connection con,
                        java.lang.String tablename)
                 throws java.sql.SQLException
Description copied from interface: DataManager
get next value for the primary key

Specified by:
getNextValue in interface DataManager
Parameters:
con - db connection
tablename - table name
Throws:
java.sql.SQLException

startTransaction

public void startTransaction(java.sql.Connection con)
                      throws java.sql.SQLException
start a DB transaction

Specified by:
startTransaction in interface DataManager
Parameters:
con - JDBC connection
Throws:
java.sql.SQLException

endTransaction

public void endTransaction(java.sql.Connection con)
                    throws java.sql.SQLException
commit transaction

Specified by:
endTransaction in interface DataManager
Parameters:
con - JDBC Connection
Throws:
java.sql.SQLException

rollbackTransaction

public void rollbackTransaction(java.sql.Connection con)
rollback transaction

Specified by:
rollbackTransaction in interface DataManager
Parameters:
con - connection

formatDate

public java.lang.String formatDate(java.util.Date date)
get a String of a date object in the databases native format useful for doing updates etc.. when not using databean objects mysql uses YYYY-MM-DD by default

Specified by:
formatDate in interface DataManager
Parameters:
date -
Returns:
formatted string of the date

getDate

public java.util.Date getDate(java.lang.String dateStr)
                       throws java.text.ParseException
get a date object by parsing a string the databases native format useful for doing updates etc.. when not using databean objects mysql uses YYYY-MM-DD by default

Specified by:
getDate in interface DataManager
Parameters:
dateStr - date text
Returns:
formatted string of the date
Throws:
java.text.ParseException

getSqlText

public java.lang.String getSqlText(java.lang.String text)
get a String that is escaped (handles ') mysql like \' not ''

Specified by:
getSqlText in interface DataManager
Parameters:
text - input text
Returns:
sql text

getTableList

public java.lang.String[] getTableList()
                                throws java.sql.SQLException
get a list of tables from the system catalog

Specified by:
getTableList in interface DataManager
Returns:
list of current tables
Throws:
java.sql.SQLException

getSequence

public Sequence getSequence()
Specified by:
getSequence in interface DataManager


Copyright(C) 2003-2006 Kevin Scott - All Rights Reserved.