|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.makumba.db.makumba.Database
org.makumba.db.makumba.sql.Database
public class Database
An SQL database, using JDBC. This class should comply with SQL-92
Field Summary | |
---|---|
(package private) boolean |
addUnderscore
|
(package private) Hashtable<String,Vector<Hashtable<String,Object>>> |
catalog
|
(package private) Properties |
connectionConfig
|
(package private) static int |
DESIRED_TRANSACTION_LEVEL
|
protected static String |
eng
|
protected com.mchange.v2.c3p0.ComboPooledDataSource |
pooledDataSource
|
(package private) static Properties |
sqlDrivers
|
(package private) String |
url
|
Fields inherited from class org.makumba.db.makumba.Database |
---|
nr, requestForeignKeys, requestUTF8, tp |
Constructor Summary | |
---|---|
Database(Properties p)
Initialize the database. |
Method Summary | |
---|---|
protected void |
checkState(SQLException e,
String state)
check the sql state of a SQL exception and throw a DBError if it is not equal with the given state |
protected void |
checkState(SQLException e,
String state,
String command)
check the sql state of a SQL exception and throw a DBError if it is not equal with the given state |
protected void |
closeResourcePool()
|
protected int |
exec(PreparedStatement ps)
execute a prepared statement and log it, and its exceptions. return the number of records affected, or -1 if a duplicate error appeared |
Map<String,String> |
getDuplicateFields(SQLException e)
|
String |
getEngine()
|
static String |
getEngineProperty(String s)
|
protected int |
getIdleConnections()
|
protected String |
getJdbcUrl(Properties p)
builds a JDBC Connection URL given the host, sqlEngine and database properties |
String |
getLimitSyntax()
|
int |
getMaxPointerValue()
|
int |
getMinPointerValue()
|
NameResolver |
getNameResolverHook()
|
protected int |
getOpenedConnections()
|
Pointer |
getPointer(String type,
int uid)
|
protected DBConnection |
getPooledDBConnection()
|
protected int |
getResourcePoolSize()
|
protected Class<?> |
getTableClass()
|
protected Class<?> |
getTableClassConfigured()
this method should be redefined by database classes that have a default table class. this returns null |
String |
getWrappedStatementToString(PreparedStatement ps)
Since we use c3p0 for connection pooling we don't get the raw prepared statement anymore but a proxy. |
boolean |
isDuplicateException(SQLException e)
return whether the exception indicates a duplicate. may need to be specified differently for certain database engines |
boolean |
isForeignKeyViolationException(SQLException se)
|
boolean |
isLimitOffsetFirst()
|
(package private) static void |
logException(SQLException e)
|
(package private) static void |
logException(SQLException e,
DBConnection dbc)
|
(package private) static void |
logException(SQLException e,
DBConnection dbc,
Level lev)
|
protected DBConnection |
makeDBConnection()
|
String |
OQLDate(Date d)
write a date into an OQL query |
String |
parseReadableForeignKeyErrorMessage(SQLException se)
Implementing classes can override this method to extract a more readable error message on foreign key errors. |
Query |
prepareQueryImpl(String oqlQuery,
String insertIn)
|
Update |
prepareUpdateImpl(String type,
String set,
String where)
|
protected void |
readCatalog(SQLDBConnection dbc)
|
static String |
SQLEscape(String s)
escapes all apostrophes from a string and puts the string into apostrophes to be added in a sql command |
static boolean |
supportsForeignKeys()
|
boolean |
supportsLimitInQuery()
whether specific engine supports LIMIT & OFFSET extensions to the SQL-92 syntax |
static boolean |
supportsUTF8()
|
Methods inherited from class org.makumba.db.makumba.Database |
---|
checkForeignKeys, close, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, deleteFrom, deleteFrom, deleteFrom, deleteFrom, finalize, findConfig, getConfiguration, getConfigurationProperties, getDBConnection, getDBConnection, getDbsv, getFieldNameInSource, getName, getNameResolver, getTable, getTable, getTypeNameInSource, initialiseTables, isAutoIncrement, makePseudoTable, openTable, openTables, usesHibernateIndexes |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
Properties connectionConfig
String url
protected static String eng
boolean addUnderscore
Hashtable<String,Vector<Hashtable<String,Object>>> catalog
static final int DESIRED_TRANSACTION_LEVEL
static Properties sqlDrivers
protected com.mchange.v2.c3p0.ComboPooledDataSource pooledDataSource
Constructor Detail |
---|
public Database(Properties p)
Method Detail |
---|
public String getEngine()
public static String getEngineProperty(String s)
public static boolean supportsUTF8()
public static boolean supportsForeignKeys()
protected DBConnection makeDBConnection()
makeDBConnection
in class Database
protected void closeResourcePool()
closeResourcePool
in class Database
protected int getResourcePoolSize()
getResourcePoolSize
in class Database
protected int getIdleConnections()
getIdleConnections
in class Database
protected int getOpenedConnections()
getOpenedConnections
in class Database
protected DBConnection getPooledDBConnection()
getPooledDBConnection
in class Database
protected void readCatalog(SQLDBConnection dbc) throws SQLException
SQLException
protected String getJdbcUrl(Properties p)
public Query prepareQueryImpl(String oqlQuery, String insertIn)
prepareQueryImpl
in class Database
public Update prepareUpdateImpl(String type, String set, String where)
prepareUpdateImpl
in class Database
public int getMinPointerValue()
getMinPointerValue
in class Database
public int getMaxPointerValue()
getMaxPointerValue
in class Database
protected Class<?> getTableClassConfigured()
Database
getTableClassConfigured
in class Database
protected Class<?> getTableClass()
public static String SQLEscape(String s)
protected void checkState(SQLException e, String state)
protected void checkState(SQLException e, String state, String command)
protected int exec(PreparedStatement ps)
public boolean isDuplicateException(SQLException e)
isDuplicateException
in class Database
public Map<String,String> getDuplicateFields(SQLException e)
getDuplicateFields
in class Database
public boolean isForeignKeyViolationException(SQLException se)
static void logException(SQLException e)
static void logException(SQLException e, DBConnection dbc)
static void logException(SQLException e, DBConnection dbc, Level lev)
public String OQLDate(Date d)
OQLDate
in class Database
public Pointer getPointer(String type, int uid)
getPointer
in class Database
public boolean supportsLimitInQuery()
public String getLimitSyntax()
public boolean isLimitOffsetFirst()
public String parseReadableForeignKeyErrorMessage(SQLException se)
public NameResolver getNameResolverHook()
public String getWrappedStatementToString(PreparedStatement ps)
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |