com.altair.hwm.database.dbmodel
Class HWMMySQLInfo

java.lang.Object
  extended by com.altair.hwm.database.dbmodel.HWMDatabaseInfo
      extended by com.altair.hwm.database.dbmodel.HWMMySQLInfo

public class HWMMySQLInfo
extends HWMDatabaseInfo

Title: Description: Copyright: Copyright (c) Company:

Version:
1.0
Author:

Field Summary
 
Fields inherited from class com.altair.hwm.database.dbmodel.HWMDatabaseInfo
AUTO_ID_TYPE, DBTYPE_ALTAIRQED, DBTYPE_MYSQL, DBTYPE_QED, TYPE_BLOB, TYPE_BOOL, TYPE_CHAR, TYPE_CLOB, TYPE_DATE, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INT, TYPE_LONG, TYPE_SHORT, TYPE_STRING
 
Constructor Summary
HWMMySQLInfo()
          Constructor
 
Method Summary
 java.sql.Connection ConnectToDB(java.lang.String strURL, int nPort, java.lang.String strDBName, java.lang.String strUser, java.lang.String strPwd, boolean bCreate)
          Returns a connection to the given database.
 java.lang.String GetAutoInc()
          Returns the SQL syntax for auto increment
 java.lang.String GetDriverID()
          Returns the driver ID for the database.
 int InsertData(java.sql.Connection cxn, java.sql.PreparedStatement prepStmt, java.lang.String strClassName)
          Insert data and retrieve the auto generated ID
 int RetrieveAutoInc(java.sql.Statement stmt)
          Returns the auto inc ID
 int RetrieveAutoInc(java.sql.Statement stmt, java.lang.String strTable)
          Returns the auto inc ID
 
Methods inherited from class com.altair.hwm.database.dbmodel.HWMDatabaseInfo
GetDriver, GetTypeMapping, GetTypes
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HWMMySQLInfo

public HWMMySQLInfo()
Constructor

Method Detail

GetAutoInc

public java.lang.String GetAutoInc()
Returns the SQL syntax for auto increment

Overrides:
GetAutoInc in class HWMDatabaseInfo
Returns:
String SQL syntax for auto increment

InsertData

public int InsertData(java.sql.Connection cxn,
                      java.sql.PreparedStatement prepStmt,
                      java.lang.String strClassName)
               throws java.lang.Exception
Insert data and retrieve the auto generated ID

Overrides:
InsertData in class HWMDatabaseInfo
Parameters:
cxn - Connection to the database.
prepStmt - The statement to execute. The same statement object is used to retrieve the auto incremented ID
strClassName - The class name into which data is being inserted
Returns:
int The value for the auto incremented ID
Throws:
java.lang.Exception

RetrieveAutoInc

public int RetrieveAutoInc(java.sql.Statement stmt)
                    throws java.lang.Exception
Returns the auto inc ID

Overrides:
RetrieveAutoInc in class HWMDatabaseInfo
Parameters:
stmt - The statement object
Returns:
int The value for the auto incremented ID
Throws:
java.lang.Exception

RetrieveAutoInc

public int RetrieveAutoInc(java.sql.Statement stmt,
                           java.lang.String strTable)
                    throws java.lang.Exception
Returns the auto inc ID

Overrides:
RetrieveAutoInc in class HWMDatabaseInfo
Parameters:
stmt - The statement object
strTable - The table to retrieve the auto inc from
Returns:
int The value for the auto incremented ID
Throws:
java.lang.Exception

ConnectToDB

public java.sql.Connection ConnectToDB(java.lang.String strURL,
                                       int nPort,
                                       java.lang.String strDBName,
                                       java.lang.String strUser,
                                       java.lang.String strPwd,
                                       boolean bCreate)
                                throws java.lang.Exception
Returns a connection to the given database. If the flag bCreate is true, then the DB is created.

Overrides:
ConnectToDB in class HWMDatabaseInfo
Parameters:
strURL - The URL to connect/create the DB
nPort - The port to connect to. ignored if set to -1.
strDBName - The database name to connect to
strUser - The user name
strPwd - The password for the user
bCreate - If true, the DB get the init packet for DB creation else DB connection.
Returns:
Connection Returns a connection to the database throws Exception
Throws:
java.lang.Exception

GetDriverID

public java.lang.String GetDriverID()
Returns the driver ID for the database. The name is not the class name. It is the name used in the address passed for connection. Example: For mysql, the address string is jdbc:mysql://url. Hence, mysql is used to identify that it is a MySQL database.

Overrides:
GetDriverID in class HWMDatabaseInfo