net.sf.colle.sql.mysql
Class MySQLRuntime

java.lang.Object
  extended bynet.sf.colle.sql.schema.RDBMSRuntime
      extended bynet.sf.colle.sql.mysql.MySQLRuntime

public class MySQLRuntime
extends RDBMSRuntime

Implementation of known differences in the MySQL RDBMS system. Created: 22 Feb 2001

Version:
$Revision: 1.10 $, $Date: 2004/07/10 04:19:04 $
Author:
Dwayne Schultz

Field Summary
 
Fields inherited from class net.sf.colle.sql.schema.RDBMSRuntime
ERROR_CONSTRAINT_VIOLATED, ERROR_DUPLICATE_ROW, ERROR_UNKNOWN
 
Constructor Summary
MySQLRuntime()
           
 
Method Summary
 void createSequence(String psSequenceName, int pnStartWith, int pnIncrementBy, Connection pxConnection)
          Create a new sequence.
 void dropSequence(String psSequenceName, Connection pxConnection)
          Drop the sequence from the database.
 String getCreatTableSuffix()
          Returns the vendor specific text to put at the end of a create table call so MySQL can turn on transactions.
 String getDatabaseURL(String psServer, String psDatabase, Integer pnPort)
          Forms a DBMS specific database URL from the information provided.
 int getErrorCode(SQLException pxException)
          Return error code (ERROR_*) for SQLException.
 int getNextValue(String psSequenceName, Connection pxConnection)
          Request a unique identifier for the following sequence name.
 ResultSet getTables(String psTable, Connection pxConnection)
          Wraps calls to DatabaseMetaData.getTables().
 boolean isIndexRequiredOnForeignKey()
          Returns true if RDBMS requires an explicit index on content before creating a foreign key.
 void loadCSVFile(Table pxTable, String psCSVFile, Connection pxConnection)
          Loads a CSV file into a table.
 void lockTables(String[] pxTableNames, Connection pxConnection)
          Locks several tables at once.
 String mapJDBCType(String psJDBCType, int pnLength, boolean pbNullable)
          Re-maps JDBC data types to vendor specific data types.
 void unlockTables(String[] pxTableName, Connection pxConnection)
          Unlocks tables previously locked with lockTables.
 
Methods inherited from class net.sf.colle.sql.schema.RDBMSRuntime
getInstance, getTruncName, lockTable, unlockTable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MySQLRuntime

public MySQLRuntime()
Method Detail

getErrorCode

public int getErrorCode(SQLException pxException)
Description copied from class: RDBMSRuntime
Return error code (ERROR_*) for SQLException.

Specified by:
getErrorCode in class RDBMSRuntime
Parameters:
pxException - SQL Exception
Returns:
Code of the error
See Also:
RDBMSRuntime

getTables

public ResultSet getTables(String psTable,
                           Connection pxConnection)
                    throws SQLException
Description copied from class: RDBMSRuntime
Wraps calls to DatabaseMetaData.getTables().

Specified by:
getTables in class RDBMSRuntime
Throws:
SQLException
See Also:
RDBMSRuntime

loadCSVFile

public void loadCSVFile(Table pxTable,
                        String psCSVFile,
                        Connection pxConnection)
Description copied from class: RDBMSRuntime
Loads a CSV file into a table.

Specified by:
loadCSVFile in class RDBMSRuntime
See Also:
RDBMSRuntime

mapJDBCType

public String mapJDBCType(String psJDBCType,
                          int pnLength,
                          boolean pbNullable)
Description copied from class: RDBMSRuntime
Re-maps JDBC data types to vendor specific data types.

Overrides:
mapJDBCType in class RDBMSRuntime
See Also:
RDBMSRuntime

getCreatTableSuffix

public String getCreatTableSuffix()
Description copied from class: RDBMSRuntime
Returns the vendor specific text to put at the end of a create table call so MySQL can turn on transactions.

Overrides:
getCreatTableSuffix in class RDBMSRuntime
See Also:
RDBMSRuntime

isIndexRequiredOnForeignKey

public boolean isIndexRequiredOnForeignKey()
Description copied from class: RDBMSRuntime
Returns true if RDBMS requires an explicit index on content before creating a foreign key.

Overrides:
isIndexRequiredOnForeignKey in class RDBMSRuntime
See Also:
RDBMSRuntime

dropSequence

public void dropSequence(String psSequenceName,
                         Connection pxConnection)
Description copied from class: RDBMSRuntime
Drop the sequence from the database.

Specified by:
dropSequence in class RDBMSRuntime
Parameters:
psSequenceName - name to sequence
pxConnection - database connection
See Also:
RDBMSRuntime

createSequence

public void createSequence(String psSequenceName,
                           int pnStartWith,
                           int pnIncrementBy,
                           Connection pxConnection)
Description copied from class: RDBMSRuntime
Create a new sequence.

Specified by:
createSequence in class RDBMSRuntime
Parameters:
psSequenceName - name to sequence
pnStartWith - starting value of the sequence
pnIncrementBy - increment by
pxConnection - database connection
See Also:
RDBMSRuntime

getNextValue

public int getNextValue(String psSequenceName,
                        Connection pxConnection)
Description copied from class: RDBMSRuntime
Request a unique identifier for the following sequence name.

Specified by:
getNextValue in class RDBMSRuntime
Parameters:
psSequenceName - name to sequence
pxConnection - database connection
Returns:
return the next value in the sequence
See Also:
RDBMSRuntime

getDatabaseURL

public String getDatabaseURL(String psServer,
                             String psDatabase,
                             Integer pnPort)
Description copied from class: RDBMSRuntime
Forms a DBMS specific database URL from the information provided. If the net.sf.colle.sql.ConnectionManager.databaseURL system property is defined this method will not be called.

Overrides:
getDatabaseURL in class RDBMSRuntime
Parameters:
psServer - IP address or computer name of the server. Will not be null.
psDatabase - name of the database. May be null if the application does not define.
pnPort - port number of the server. May be null if the application does not define.
See Also:
RDBMSRuntime

lockTables

public void lockTables(String[] pxTableNames,
                       Connection pxConnection)
                throws SQLException
Description copied from class: RDBMSRuntime
Locks several tables at once. Implementations do need to override lockTable() as the default version of lockTable() calls lockTables().

Overrides:
lockTables in class RDBMSRuntime
Throws:
SQLException
See Also:
RDBMSRuntime

unlockTables

public void unlockTables(String[] pxTableName,
                         Connection pxConnection)
                  throws SQLException
Description copied from class: RDBMSRuntime
Unlocks tables previously locked with lockTables. Implementations do need to override unlockTable() as the default version of unlockTable() calls unlockTables().

Overrides:
unlockTables in class RDBMSRuntime
Throws:
SQLException
See Also:
RDBMSRuntime