goldengate.common.database.model
Class DbModelMysql

java.lang.Object
  extended by goldengate.common.database.model.DbModelAbstract
      extended by goldengate.common.database.model.DbModelMysql
All Implemented Interfaces:
DbModel

public abstract class DbModelMysql
extends DbModelAbstract

MySQL Database Model implementation

Author:
Frederic Bregier

Nested Class Summary
protected static class DbModelMysql.DBType
           
 
Field Summary
protected static com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource mysqlConnectionPoolDataSource
           
protected static DbConnectionPool pool
           
static DbType type
           
 
Constructor Summary
protected DbModelMysql()
          Create the object and initialize if necessary the driver
  DbModelMysql(String dbserver, String dbuser, String dbpasswd)
          Create the object and initialize if necessary the driver
  DbModelMysql(String dbserver, String dbuser, String dbpasswd, org.jboss.netty.util.Timer timer, long delay)
          Create the object and initialize if necessary the driver
 
Method Summary
 void createTables(DbSession session)
          Create all necessary tables into the database
 int currentNumberOfPooledConnections()
           
 Connection getDbConnection(String server, String user, String passwd)
           
 DbType getDbType()
           
 String limitRequest(String allfields, String request, int nb)
          Add a limit on the request to get the "limit" first rows.
 long nextSequence(DbSession dbSession)
           
 void releaseResources()
          Release any internal resources if needed
 void resetSequence(DbSession session, long newvalue)
          Reset the sequence (example)
protected  String validConnectionString()
           
 
Methods inherited from class goldengate.common.database.model.DbModelAbstract
closeInternalConnection, validConnection, validConnectionSelect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

public static DbType type

mysqlConnectionPoolDataSource

protected static com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource mysqlConnectionPoolDataSource

pool

protected static DbConnectionPool pool
Constructor Detail

DbModelMysql

public DbModelMysql(String dbserver,
                    String dbuser,
                    String dbpasswd,
                    org.jboss.netty.util.Timer timer,
                    long delay)
             throws GoldenGateDatabaseNoConnectionException
Create the object and initialize if necessary the driver

Parameters:
dbserver -
dbuser -
dbpasswd -
timer -
delay -
Throws:
GoldenGateDatabaseNoConnectionException

DbModelMysql

public DbModelMysql(String dbserver,
                    String dbuser,
                    String dbpasswd)
             throws GoldenGateDatabaseNoConnectionException
Create the object and initialize if necessary the driver

Parameters:
dbserver -
dbuser -
dbpasswd -
Throws:
GoldenGateDatabaseNoConnectionException

DbModelMysql

protected DbModelMysql()
                throws GoldenGateDatabaseNoConnectionException
Create the object and initialize if necessary the driver

Throws:
GoldenGateDatabaseNoConnectionException
Method Detail

getDbType

public DbType getDbType()
Returns:
the current DbType used

releaseResources

public void releaseResources()
Description copied from interface: DbModel
Release any internal resources if needed

Specified by:
releaseResources in interface DbModel
Overrides:
releaseResources in class DbModelAbstract

currentNumberOfPooledConnections

public int currentNumberOfPooledConnections()
Specified by:
currentNumberOfPooledConnections in interface DbModel
Overrides:
currentNumberOfPooledConnections in class DbModelAbstract
Returns:
the number of Pooled Connections if any

getDbConnection

public Connection getDbConnection(String server,
                                  String user,
                                  String passwd)
                           throws SQLException
Specified by:
getDbConnection in interface DbModel
Overrides:
getDbConnection in class DbModelAbstract
Returns:
a connection according to the underlying Database Model
Throws:
SQLException

createTables

public void createTables(DbSession session)
                  throws GoldenGateDatabaseNoConnectionException
Description copied from interface: DbModel
Create all necessary tables into the database

Parameters:
session - SQL session
Throws:
GoldenGateDatabaseNoConnectionException

resetSequence

public void resetSequence(DbSession session,
                          long newvalue)
                   throws GoldenGateDatabaseNoConnectionException
Description copied from interface: DbModel
Reset the sequence (example)

Parameters:
session - SQL session
Throws:
GoldenGateDatabaseNoConnectionException

nextSequence

public long nextSequence(DbSession dbSession)
                  throws GoldenGateDatabaseNoConnectionException,
                         GoldenGateDatabaseSqlException,
                         GoldenGateDatabaseNoDataException
Returns:
The next unique specialId
Throws:
GoldenGateDatabaseNoConnectionException
GoldenGateDatabaseSqlException
GoldenGateDatabaseNoDataException

validConnectionString

protected String validConnectionString()
Specified by:
validConnectionString in class DbModelAbstract
Returns:
the associated String to validate the connection (as "select 1 frm dual")

limitRequest

public String limitRequest(String allfields,
                           String request,
                           int nb)
Description copied from interface: DbModel
Add a limit on the request to get the "limit" first rows. Note that it must be compatible to add the "limit" condition.
DO NOT CHANGE (add) ANYTHING to the request
On Oracle: select allfield from (request) where rownnum <= limit
On others: request LIMIT limit

Parameters:
allfields - string representing the equivalent to "*" in "select *" but more precisely as "field1, field2" in "select field1, field2"
Returns:
the new request String which will limit the result to the specified number of rows


Copyright © 2009-2012 Frederic Bregier. All Rights Reserved.