com.altair.hwm.database.dbmodel
Class HWMDatabaseInfo

java.lang.Object
  extended by com.altair.hwm.database.dbmodel.HWMDatabaseInfo
Direct Known Subclasses:
HWMEmbeddedDBInfo, HWMMySQLInfo, HWMQEDInfo

public class HWMDatabaseInfo
extends java.lang.Object

Title: HWMDatabaseInfo

Description: This class will be implemented by classes that represent a particular database. This interface can be used to retrieve the types supported by a database and also the syntax

Company: Altair Engineering, Inc.


Field Summary
static java.lang.String AUTO_ID_TYPE
          The type for auto id
static java.lang.String DBTYPE_ALTAIRQED
           
static java.lang.String DBTYPE_MYSQL
           
static java.lang.String DBTYPE_QED
          The type of database
static java.lang.String TYPE_BLOB
          The type for blob
static java.lang.String TYPE_BOOL
          The type for bool
static java.lang.String TYPE_CHAR
          The type for char
static java.lang.String TYPE_CLOB
          The type for clob
static java.lang.String TYPE_DATE
          The type for date
static java.lang.String TYPE_DOUBLE
          The type for double
static java.lang.String TYPE_FLOAT
          The type for float
static java.lang.String TYPE_INT
          The type for Integer
static java.lang.String TYPE_LONG
          The type for long
static java.lang.String TYPE_SHORT
          The type for short
static java.lang.String TYPE_STRING
          The type for string
 
Constructor Summary
HWMDatabaseInfo()
           
 
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 GetDriver()
          Returns the driver name
 java.lang.String GetDriverID()
          Returns the driver ID for the database.
 java.util.Hashtable GetTypeMapping()
          Returns the hashtable that maps the datamodel's generic types to data types supported by the database
static java.lang.String[] GetTypes()
          Returns the types that the data model supports
 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 java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTO_ID_TYPE

public static final java.lang.String AUTO_ID_TYPE
The type for auto id

See Also:
Constant Field Values

TYPE_BLOB

public static final java.lang.String TYPE_BLOB
The type for blob

See Also:
Constant Field Values

TYPE_INT

public static final java.lang.String TYPE_INT
The type for Integer

See Also:
Constant Field Values

TYPE_FLOAT

public static final java.lang.String TYPE_FLOAT
The type for float

See Also:
Constant Field Values

TYPE_DOUBLE

public static final java.lang.String TYPE_DOUBLE
The type for double

See Also:
Constant Field Values

TYPE_LONG

public static final java.lang.String TYPE_LONG
The type for long

See Also:
Constant Field Values

TYPE_DATE

public static final java.lang.String TYPE_DATE
The type for date

See Also:
Constant Field Values

TYPE_SHORT

public static final java.lang.String TYPE_SHORT
The type for short

See Also:
Constant Field Values

TYPE_CLOB

public static final java.lang.String TYPE_CLOB
The type for clob

See Also:
Constant Field Values

TYPE_BOOL

public static final java.lang.String TYPE_BOOL
The type for bool

See Also:
Constant Field Values

TYPE_STRING

public static final java.lang.String TYPE_STRING
The type for string

See Also:
Constant Field Values

TYPE_CHAR

public static final java.lang.String TYPE_CHAR
The type for char

See Also:
Constant Field Values

DBTYPE_QED

public static final java.lang.String DBTYPE_QED
The type of database

See Also:
Constant Field Values

DBTYPE_MYSQL

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

DBTYPE_ALTAIRQED

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

HWMDatabaseInfo

public HWMDatabaseInfo()
Method Detail

GetTypes

public static java.lang.String[] GetTypes()
Returns the types that the data model supports

Returns:
String[] The data types supported by data model

GetTypeMapping

public java.util.Hashtable GetTypeMapping()
Returns the hashtable that maps the datamodel's generic types to data types supported by the database

Returns:
Hashtable The data types supported by database

GetAutoInc

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

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

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

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

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

GetDriver

public java.lang.String GetDriver()
Returns the driver name

Returns:
String The driver name

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.

Parameters:
strURL - The URL to connect/create the DB
nPort - The port to which to connect to. If -1 then it is ignored
strDBName - The database name o 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.