|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.beans.Beans
com.knowgate.dataobjs.DBBind
public class DBBind
Singleton object for database binding.
| Nested Class Summary | |
|---|---|
static class |
DBBind.Functions
Aliases for common SQL functions in different database dialects. |
| Field Summary | |
|---|---|
static int |
DBMS_ACCESS
|
static int |
DBMS_GENERIC
|
static int |
DBMS_MSSQL
|
static int |
DBMS_MYSQL
|
static int |
DBMS_ORACLE
|
static int |
DBMS_POSTGRESQL
|
| Constructor Summary | |
|---|---|
DBBind()
Create DBBind. |
|
DBBind(java.lang.String sProfile)
Create DBBind. |
|
| Method Summary | |
|---|---|
void |
close()
Close DBBind Close connections from pool. |
JDCConnectionPool |
connectionPool()
Get connection pool used by this database binding |
static int |
currVal(java.sql.Connection oSQLConn,
java.lang.String sSequenceName)
Get current value for a sequence |
static int |
currVal(JDCConnection oConn,
java.lang.String sSequenceName)
Get current value for a sequence |
static java.lang.String |
escape(java.util.Date dt,
java.lang.String sFormat)
Format Date in ODBC escape sequence style |
static java.lang.String |
escape(java.sql.Timestamp ts,
java.lang.String sFormat)
Format Timestamp in ODBC escape sequence style |
static boolean |
exists(JDCConnection oConn,
java.lang.String sObjectName,
java.lang.String sObjectType)
Checks if an object exists at database Checking is done directly against database catalog tables, if current user does not have enought priviledges for reading database catalog tables methos may fail or return a wrong result. |
java.sql.Connection |
getConnection()
Get a Connection instance from connection pool |
JDCConnection |
getConnection(java.lang.String sCaller)
Get a JDCConnection instance from connection pool |
java.sql.Connection |
getConnection(java.lang.String sUser,
java.lang.String sPasswd)
Get a Connection instance directly from the database bypassing the pool |
java.lang.String |
getDatabaseProductName()
Get the name of Database Management System Connected |
static java.lang.String |
getDataModelVersion(JDCConnection oConn)
Get datamodel version |
static int |
getDataModelVersionNumber(JDCConnection oConn)
Get datamodel version number |
DBTable |
getDBTable(java.lang.String sTable)
Get DBTable object by name |
java.util.HashMap |
getDBTablesMap()
Get map of DBTable objects |
int |
getLoginTimeout()
Get login timeout from java.sql.DriverManager |
java.io.PrintWriter |
getLogWriter()
Get LogWriter from java.sql.DriverManager |
java.lang.String |
getProfileName()
Get Name of profile used for initializing DBBind Profile Name is the properties file name ("hipergate.cnf") without extension. |
java.util.Properties |
getProperties()
Get properties from the .CNF file for this DBBind. |
java.lang.String |
getProperty(java.lang.String sVarName)
Get a single property from the .CNF file for this DBBind. |
java.lang.String |
getProperty(java.lang.String sVarName,
java.lang.String sDefault)
Get a single property from the .CNF file for this DBBind. |
boolean |
getPropertyBool(java.lang.String sVarName,
boolean bDefault)
Get a boolean property from the .CNF file for this DBBind. |
java.lang.String |
getPropertyPath(java.lang.String sVarName)
Get a property representing a file path from the .CNF file for this DBBind. |
static DBTable |
getTable(java.lang.String sTable)
Deprecated. Use getDBTable instead |
static long |
getTime()
|
protected void |
initialize(java.lang.String sProfile)
|
boolean |
isWrapperFor(java.lang.Class c)
|
static int |
nextVal(java.sql.Connection oSQLConn,
java.lang.String sSequenceName)
Get next value for a sequence |
static int |
nextVal(JDCConnection oConn,
java.lang.String sSequenceName)
Get next value for a sequence |
void |
restart()
Close and reopen the connection pool and reload the table map cache |
void |
setLoginTimeout(int seconds)
Set login timeout for java.sql.DriverManager |
void |
setLogWriter(java.io.PrintWriter printwrt)
Set LogWriter for java.sql.DriverManager |
java.lang.Object |
unwrap(java.lang.Class c)
|
| Methods inherited from class java.beans.Beans |
|---|
getInstanceOf, instantiate, instantiate, instantiate, isDesignTime, isGuiAvailable, isInstanceOf, setDesignTime, setGuiAvailable |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DBMS_GENERIC
public static final int DBMS_MYSQL
public static final int DBMS_POSTGRESQL
public static final int DBMS_MSSQL
public static final int DBMS_ORACLE
public static final int DBMS_ACCESS
| Constructor Detail |
|---|
public DBBind()
Create DBBind.
Read database connection properties from hipergate.cnf.
public DBBind(java.lang.String sProfile)
Create DBBind.
Read database connection properties from specified properties file.
sProfile - Name of properties file without extension.| Method Detail |
|---|
public void close()
Close DBBind
Close connections from pool.
public void restart()
throws java.sql.SQLException,
java.lang.ClassNotFoundException
java.sql.SQLException
java.lang.ClassNotFoundExceptionpublic JDCConnectionPool connectionPool()
protected void initialize(java.lang.String sProfile)
throws java.lang.ClassNotFoundException,
java.sql.SQLException,
java.lang.NullPointerException,
java.security.AccessControlException,
java.lang.UnsatisfiedLinkError,
java.lang.NumberFormatException
java.lang.ClassNotFoundException
java.sql.SQLException
java.lang.NullPointerException
java.security.AccessControlException
java.lang.UnsatisfiedLinkError
java.lang.NumberFormatException
public java.lang.String getDatabaseProductName()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String getProfileName()
Get Name of profile used for initializing DBBind
Profile Name is the properties file name ("hipergate.cnf") without extension.
public java.util.Properties getProperties()
Get properties from the .CNF file for this DBBind.
public java.lang.String getProperty(java.lang.String sVarName)
Get a single property from the .CNF file for this DBBind.
sVarName - Property Name
public java.lang.String getProperty(java.lang.String sVarName,
java.lang.String sDefault)
Get a single property from the .CNF file for this DBBind.
sVarName - Property NamesDefault - Default Value
public boolean getPropertyBool(java.lang.String sVarName,
boolean bDefault)
Get a boolean property from the .CNF file for this DBBind.
sVarName - Property NamebDefault - Default Value
public java.lang.String getPropertyPath(java.lang.String sVarName)
Get a property representing a file path from the .CNF file for this DBBind.
sVarName - Property Name
public static boolean exists(JDCConnection oConn,
java.lang.String sObjectName,
java.lang.String sObjectType)
throws java.sql.SQLException,
java.lang.UnsupportedOperationException
oConn - Database connectionsObjectName - Objeto namesObjectType - Objeto type
C = CHECK constraint
D = Default or DEFAULT constraint
F = FOREIGN KEY constraint
L = Log
P = Stored procedure
PK = PRIMARY KEY constraint (type is K)
RF = Replication filter stored procedure
S = System table
TR = Trigger
U = User table
UQ = UNIQUE constraint (type is K)
V = View
X = Extended stored procedure
java.sql.SQLException
java.lang.UnsupportedOperationException - If current database management system is not supported for this method
public static java.lang.String getDataModelVersion(JDCConnection oConn)
throws java.sql.SQLException
oConn - JDCConnection object
java.sql.SQLException
public static int getDataModelVersionNumber(JDCConnection oConn)
throws java.sql.SQLException
oConn - JDCConnection object
java.sql.SQLException
public static int currVal(JDCConnection oConn,
java.lang.String sSequenceName)
throws java.sql.SQLException,
java.lang.UnsupportedOperationException
Get current value for a sequence
oConn - JDCConnectionsSequenceName - Sequence name.
In MySQL and SQL Server sequences are implemented using row locks at k_sequences table.
java.sql.SQLException
java.lang.UnsupportedOperationException - Not all databases support sequences.
On Oracle and PostgreSQL, native SEQUENCE objects are used,
on MySQL and Microsoft SQL Server the stored procedure k_sp_currval simulates sequences,
this function is not supported on other DataBase Management Systems.
public static int currVal(java.sql.Connection oSQLConn,
java.lang.String sSequenceName)
throws java.sql.SQLException,
java.lang.UnsupportedOperationException
Get current value for a sequence
oSQLConn - Database connectionsSequenceName - Sequence name.
In MySQL and SQL Server sequences are implemented using row locks at k_sequences table.
java.sql.SQLException
java.lang.UnsupportedOperationException - Not all databases support sequences.
On Oracle and PostgreSQL, native SEQUENCE objects are used,
on MySQL and Microsoft SQL Server the stored procedure k_sp_nextval simulates sequences,
this function is not supported on other DataBase Management Systems.
public static int nextVal(JDCConnection oConn,
java.lang.String sSequenceName)
throws java.sql.SQLException,
java.lang.UnsupportedOperationException
Get next value for a sequence
oConn - JDCConnectionsSequenceName - Sequence name.
In MySQL and SQL Server sequences are implemented using row locks at k_sequences table.
java.sql.SQLException
java.lang.UnsupportedOperationException - Not all databases support sequences.
On Oracle and PostgreSQL, native SEQUENCE objects are used,
on Microsoft SQL Server the stored procedure k_sp_nextval simulates sequences,
this function is not supported on other DataBase Management Systems.
public static int nextVal(java.sql.Connection oSQLConn,
java.lang.String sSequenceName)
throws java.sql.SQLException,
java.lang.UnsupportedOperationException
Get next value for a sequence
oSQLConn - Database connectionsSequenceName - Sequence name.
In MySQL and SQL Server sequences are implemented using row locks at k_sequences table.
java.sql.SQLException
java.lang.UnsupportedOperationException - Not all databases support sequences.
On Oracle and PostgreSQL, native SEQUENCE objects are used,
on Microsoft SQL Server the stored procedure k_sp_nextval simulates sequences,
this function is not supported on other DataBase Management Systems.
public static java.lang.String escape(java.util.Date dt,
java.lang.String sFormat)
throws java.lang.IllegalArgumentException
dt - Date to be formatedsFormat - Format Type "d" or "ts" or "shortTime".
Use d for { d 'yyyy-mm-dd' }, use ts for { ts 'ts=yyyy-mm-dd hh:nn:ss' }java.lang.IllegalArgumentException - if dt is of type java.sql.Date
public static java.lang.String escape(java.sql.Timestamp ts,
java.lang.String sFormat)
ts - Timestamp to be formatedsFormat - Format Type "d" or "ts" or "shortTime".
Use d for { d 'yyyy-mm-dd' }, use ts for { ts 'ts=yyyy-mm-dd hh:nn:ss' }
public static DBTable getTable(java.lang.String sTable)
throws java.lang.IllegalStateException
getDBTable instead
Get DBTable object by name
sTable - Table name
java.lang.IllegalStateException - DBTable objects are cached in a static HasMap,
the HashMap is loaded upon first call to a DBBind constructor. If getTable()
is called before creating any instance of DBBind an IllegalStateException
will be raised.
public DBTable getDBTable(java.lang.String sTable)
throws java.lang.IllegalStateException
Get DBTable object by name
sTable - Table name
java.lang.IllegalStateException - DBTable objects are cached in a static HasMap,
the HashMap is loaded upon first call to a DBBind constructor.
If getDBTable() is called before creating any instance of DBBind then an
IllegalStateException will be thrown.
public java.util.HashMap getDBTablesMap()
throws java.lang.IllegalStateException
Get map of DBTable objects
java.lang.IllegalStateException - DBTable objects are cached in a static HasMap,
the HashMap is loaded upon first call to a DBBind constructor.
If getDBTablesMap() is called before creating any instance of DBBind
then an IllegalStateException will be thrown.
public JDCConnection getConnection(java.lang.String sCaller)
throws java.sql.SQLException
Get a JDCConnection instance from connection pool
sCaller - Symbolic name identifying the caller program or subroutine,
this field is used for statistical control of database accesses,
performance tunning and debugging open/close mismatch.
java.sql.SQLException
public java.sql.Connection getConnection()
throws java.sql.SQLException
Get a Connection instance from connection pool
getConnection in interface javax.sql.DataSourcesCaller - Symbolic name identifying the caller program or subroutine,
this field is used for statistical control of database accesses,
performance tunning and debugging open/close mismatch.
java.sql.SQLException
public java.sql.Connection getConnection(java.lang.String sUser,
java.lang.String sPasswd)
throws java.sql.SQLException
Get a Connection instance directly from the database bypassing the pool
getConnection in interface javax.sql.DataSourcesUser - User namesPasswd - Password
java.sql.SQLException
public java.io.PrintWriter getLogWriter()
throws java.sql.SQLException
getLogWriter in interface javax.sql.CommonDataSourcejava.sql.SQLException
public void setLogWriter(java.io.PrintWriter printwrt)
throws java.sql.SQLException
setLogWriter in interface javax.sql.CommonDataSourcejava.sql.SQLException
public int getLoginTimeout()
throws java.sql.SQLException
getLoginTimeout in interface javax.sql.CommonDataSourcejava.sql.SQLException
public void setLoginTimeout(int seconds)
throws java.sql.SQLException
setLoginTimeout in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic boolean isWrapperFor(java.lang.Class c)
isWrapperFor in interface java.sql.Wrapperpublic java.lang.Object unwrap(java.lang.Class c)
unwrap in interface java.sql.Wrapperpublic static long getTime()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||