|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnl.knowledgeplaza.util.JdbcUtil
public class JdbcUtil
Several convenience methods for JDBC related tasks. TODO: can we push in some pooling and optional caching? TODO: we use a list-of-maps, which is very memory intensive. A map-of-lists would be better, or even beter: a single class encapsulating that (ResultSet? HA!).
| Nested Class Summary | |
|---|---|
static class |
JdbcUtil.JdbcList
|
static class |
JdbcUtil.JdbcMap
|
static class |
JdbcUtil.Preprocess
An interface for Preprocessing during the run |
static class |
JdbcUtil.SyncDescriptor
Class that provides all data needed for the synchronizeTableFullOneWay methods. |
| Field Summary | |
|---|---|
static java.lang.String[] |
EMPTY_STRING_ARRAY
|
static java.lang.String |
SOURCECODE_VERSION
Standard variable for determining version of a class file. |
| Constructor Summary | |
|---|---|
JdbcUtil()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
buildSqlDeleteStatement(java.lang.String tablename,
java.lang.String[] keys)
Build the SQL statement that checks if a certain record exists select 1 from table where key=?, ... |
static java.lang.String |
buildSqlInsertStatement(java.lang.String tablename,
java.lang.String[] fields,
java.lang.String[] keys)
Build an insert statement with the same parameter list as the update statement would have. |
static java.lang.String |
buildSqlSelectAllStatement(java.lang.String tablename,
java.lang.String[] fields,
java.lang.String[] keys)
|
static java.lang.String |
buildSqlSelectAllStatement(java.lang.String tablename,
java.lang.String[] fields,
java.lang.String[] keys,
java.lang.String whereclause)
Build the SQL statement that selects the specified fields of one record select field, ... |
static java.lang.String |
buildSqlSelectChangedStatement(java.lang.String tablename,
java.lang.String[] fields,
java.lang.String[] keys)
Build the select statement that checks if any of the fields of the record have changed (using the key to identify record) select 1 from table where (fields<>? or ...) and key=? and ... |
static java.lang.String |
buildSqlSelectExistsStatement(java.lang.String tablename,
java.lang.String[] keys)
|
static java.lang.String |
buildSqlSelectExistsStatement(java.lang.String tablename,
java.lang.String[] keys,
java.lang.String whereclause)
Build the SQL statement that checks if a certain record exists select 1 from table where key=?, ... |
static java.lang.String |
buildSqlSelectStatement(java.lang.String tablename,
java.lang.String[] fields,
java.lang.String[] keys)
Build the SQL statement that selects the specified fields of one record select field, ... |
static java.lang.String |
buildSqlUpdateStatement(java.lang.String tablename,
java.lang.String[] fields,
java.lang.String[] keys)
Build an update statement with the same parameter list as the insert statement would have. |
static java.sql.Connection |
close(java.sql.Connection c)
Close and wrap the possible but highly unlikely exception in a RuntimeException |
static java.sql.PreparedStatement |
close(java.sql.PreparedStatement c)
Close and wrap the possible but highly unlikely exception in a RuntimeException |
static java.sql.ResultSet |
close(java.sql.ResultSet c)
Close and wrap the possible but highly unlikely exception in a RuntimeException |
static java.sql.Statement |
close(java.sql.Statement c)
Close and wrap the possible but highly unlikely exception in a RuntimeException |
static void |
commit(java.sql.Connection connection)
Commit but throw a runtime exception instead of a SQLExeception. |
static int |
determineColumnType(java.sql.Connection connection,
java.lang.String tableAndColumnName)
Return the java.sql.Types for a column NOTE: it may be smart to cache the results |
static int |
determineColumnType(java.sql.Connection connection,
java.lang.String tableName,
java.lang.String columnName)
Return the java.sql.Types for a column NOTE: it may be smart to cache the results |
static int |
execute(java.sql.Connection connection,
SqlBuilder sqlBuilder)
|
static int |
execute(java.sql.Connection connection,
java.lang.String sql)
Execute a single SQL |
static int |
execute(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object... parameters)
Execute a single SQL with parameters |
static int |
execute(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
|
static int |
execute(java.sql.PreparedStatement preparedStatement)
|
static int |
execute(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
|
static int |
execute(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
Execute a single SQL with parameters |
static java.lang.Object |
getDefaultValueFor(int lType)
Return a default value for all java.sql.Types |
static int |
getFieldLength(java.sql.Connection connection,
java.lang.String tablenamePlusColumnname)
Determines the length of a field using metadata |
static int |
getFieldLength(java.sql.Connection connection,
java.lang.String tablename,
java.lang.String columnname)
Determines the length of a field using metadata |
static java.lang.Number |
getNextValueFromSequenceTable(java.sql.Connection connection,
java.lang.String id)
Get a single value from the sequence table: create table seq(seq_id varchar(20), seq_val integer default 0, primary key(seq_id)); |
static java.lang.Number |
getNextValueFromSequenceTable(java.sql.Connection connection,
java.lang.String tableName,
java.lang.String idColumnName,
java.lang.String id,
java.lang.String valueColumnName)
Get a single value from a sequence table |
static java.lang.Number |
getNextValueFromSequenceTable(java.sql.Connection connection,
java.lang.String tableName,
java.lang.String idColumnName,
java.lang.String id,
java.lang.String valueColumnName,
int increment)
Get a value block from a sequence table |
static java.lang.Number |
getNextValueFromSequenceTableAndCheck(java.sql.Connection connection,
java.lang.String tableName,
java.lang.String idColumnName,
java.lang.String id,
java.lang.String valueColumnName,
java.lang.String sql,
int maxTries)
Get a single value from a sequence table |
static boolean |
hasAtLeastOneRecord(java.sql.Connection connection,
SqlBuilder sqlBuilder)
|
static boolean |
hasAtLeastOneRecord(java.sql.Connection connection,
java.lang.String sql)
|
static boolean |
hasAtLeastOneRecord(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object... parameters)
Check to see if the resultset has enough records |
static boolean |
hasAtLeastOneRecord(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
|
static boolean |
hasAtLeastOneRecord(java.sql.PreparedStatement preparedStatement)
|
static boolean |
hasAtLeastOneRecord(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
|
static boolean |
hasAtLeastOneRecord(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
Check to see if the resultset has enough records |
static boolean |
hasEnoughRecords(java.sql.Connection connection,
SqlBuilder sqlBuilder)
|
static boolean |
hasEnoughRecords(java.sql.Connection connection,
java.lang.String sql)
|
static boolean |
hasEnoughRecords(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
|
static boolean |
hasEnoughRecords(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters,
int numberOfRecords)
Check to see if the resultset has enough records |
static boolean |
hasEnoughRecords(java.sql.PreparedStatement preparedStatement)
|
static boolean |
hasEnoughRecords(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
|
static boolean |
hasEnoughRecords(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters,
int numberOfRecords)
Check to see if the resultset has enough records |
static boolean |
isColumnTypeDateOrTime(int type)
Determine if the java.sql.Types is a date |
static boolean |
isColumnTypeNumber(int type)
Determine if the java.sql.Types is a number |
static boolean |
isColumnTypeString(int type)
Determine if the java.sql.Types is a date |
static void |
main(java.lang.String[] args)
Some quick unit tests |
static java.lang.Object |
query(java.sql.Connection connection,
java.lang.String sql)
Fetch one row, one field |
static java.lang.Object |
query(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
Fetch one row, one field |
static java.lang.Object |
query(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
Fetch one row, one field |
static java.util.Map |
queryAsKeyValueMap(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
Fetch key value pairs (1st first is key, 2nd is value, rest is ignored) |
static java.util.Map |
queryAsKeyValueMap(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
Fetch key value pairs (1st first is key, 2nd is value, rest is ignored) |
static java.util.List |
queryAsList(java.sql.Connection connection,
java.lang.String sql)
Fetch multiple rows, one field |
static java.util.List |
queryAsList(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
Fetch multiple rows, one field |
static java.util.List |
queryAsList(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
Fetch multiple rows, one field |
static JdbcUtil.JdbcList |
queryAsListOfMaps(java.sql.Connection connection,
java.lang.String sql)
Fetch multiple rows, multiple fields |
static JdbcUtil.JdbcList |
queryAsListOfMaps(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
Fetch multiple rows, multiple fields |
static JdbcUtil.JdbcList |
queryAsListOfMaps(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
Fetch multiple rows, multiple fields |
static JdbcUtil.JdbcMap |
queryAsMap(java.sql.Connection connection,
java.lang.String sql)
Fetch one row, multiple fields |
static JdbcUtil.JdbcMap |
queryAsMap(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
Fetch one row, multiple fields |
static JdbcUtil.JdbcMap |
queryAsMap(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
Fetch one row, multiple fields |
static void |
rollback(java.sql.Connection connection)
Commit but throw a runtime exception instead of a SQLExeception. |
static java.lang.Object |
sanatizeParameter(java.lang.Object p)
try to convert parameters to something JDBC will accept, like Calendar to java.sql.Date |
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(java.sql.Connection connection,
SqlBuilder sqlBuilder)
|
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(java.sql.Connection connection,
java.lang.String sql)
|
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
|
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
|
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(java.sql.PreparedStatement preparedStatement)
|
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
|
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
|
static java.util.List |
selectManyRowsFirstField(java.sql.Connection connection,
SqlBuilder sqlBuilder)
|
static java.util.List |
selectManyRowsFirstField(java.sql.Connection connection,
java.lang.String sql)
|
static java.util.List |
selectManyRowsFirstField(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
|
static java.util.List |
selectManyRowsFirstField(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
|
static java.util.List |
selectManyRowsFirstField(java.sql.PreparedStatement preparedStatement)
|
static java.util.List |
selectManyRowsFirstField(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
|
static java.util.List |
selectManyRowsFirstField(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
|
static java.util.Map |
selectManyRowsFirstTwoFieldsAsKeyValueMap(java.sql.Connection connection,
SqlBuilder sqlBuilder)
|
static java.util.Map |
selectManyRowsFirstTwoFieldsAsKeyValueMap(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
|
static java.util.Map |
selectManyRowsFirstTwoFieldsAsKeyValueMap(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
|
static java.util.Map |
selectManyRowsFirstTwoFieldsAsKeyValueMap(java.sql.PreparedStatement preparedStatement)
|
static java.util.Map |
selectManyRowsFirstTwoFieldsAsKeyValueMap(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
|
static java.util.Map |
selectManyRowsFirstTwoFieldsAsKeyValueMap(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(java.sql.Connection connection,
SqlBuilder sqlBuilder)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(java.sql.Connection connection,
java.lang.String sql)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(java.sql.PreparedStatement preparedStatement)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
|
static java.lang.Object |
selectOneRowOneField(java.sql.Connection connection,
SqlBuilder sqlBuilder)
|
static java.lang.Object |
selectOneRowOneField(java.sql.Connection connection,
java.lang.String sql)
|
static java.lang.Object |
selectOneRowOneField(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object... parameters)
|
static java.lang.Object |
selectOneRowOneField(java.sql.PreparedStatement preparedStatement)
|
static java.lang.Object |
selectOneRowOneField(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
|
static java.lang.Object |
selectOneRowOneField(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
|
static void |
setParameters(java.sql.PreparedStatement preparedStatement,
java.lang.Object... parameters)
set parameters to a prepared statement |
static void |
synchronizeTableFullOneWay_Copy(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String fromTablename,
java.lang.String toTablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j,
JdbcUtil.Preprocess preprocess)
Insert in the table in the to connection with any missing records in relation to the from connection |
static void |
synchronizeTableFullOneWay_Delete(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String tablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
Remove any records in the to connection that do not exist in the form connection |
static void |
synchronizeTableFullOneWay_Delete(java.sql.Connection fromConnection,
java.lang.String fromTablename,
java.lang.String[] fromKeys,
java.lang.String[] fromFields,
java.sql.Connection toConnection,
java.lang.String toTablename,
java.lang.String[] toKeys,
java.lang.String[] toFields,
int commitEvery,
org.apache.log4j.Logger log4j)
Remove any records in the to connection that do not exist in the form connection |
static void |
synchronizeTableFullOneWay_Delete(JdbcUtil.SyncDescriptor syncDescriptor,
org.apache.log4j.Logger log4j)
Remove any records in the to connection that do not exist in the form connection |
static void |
synchronizeTableFullOneWay_Insert(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String tablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
Insert in the table in the to connection with any missing records in relation to the from connection |
static void |
synchronizeTableFullOneWay_Insert(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String fromTablename,
java.lang.String toTablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
Insert in the table in the to connection with any missing records in relation to the from connection |
static void |
synchronizeTableFullOneWay_Insert(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String fromTablename,
java.lang.String toTablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j,
JdbcUtil.Preprocess preprocess)
Insert in the table in the to connection with any missing records in relation to the from connection |
static void |
synchronizeTableFullOneWay_InsertUpdate(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String tablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
Update the table in the to connection with any missing records in relation to the from connection |
static void |
synchronizeTableFullOneWay_InsertUpdate(java.sql.Connection fromConnection,
java.lang.String fromTablename,
java.lang.String[] fromKeys,
java.lang.String[] fromFields,
java.sql.Connection toConnection,
java.lang.String toTablename,
java.lang.String[] toKeys,
java.lang.String[] toFields,
int commitEvery,
org.apache.log4j.Logger log4j)
Update the table in the to connection with any missing records in relation to the from connection |
static void |
synchronizeTableFullOneWay_InsertUpdate(JdbcUtil.SyncDescriptor syncDescriptor,
org.apache.log4j.Logger log4j)
Update the table in the to connection with any missing records in relation to the from connection |
static void |
synchronizeTableFullOneWay(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String tablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
Insert, update or delete record so that the table in the to connection becomes identical to the from connection |
static void |
synchronizeTableFullOneWay(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String fromSchemaName,
java.lang.String fromTablename,
int commitEvery,
org.apache.log4j.Logger log4j)
Sync a table with all fields |
static void |
synchronizeTableFullOneWay(java.sql.Connection fromConnection,
java.lang.String fromTablename,
java.lang.String[] fromKeys,
java.lang.String[] fromFields,
java.sql.Connection toConnection,
java.lang.String toTablename,
java.lang.String[] toKeys,
java.lang.String[] toFields,
int commitEvery,
org.apache.log4j.Logger log4j)
Insert, update or delete record so that the table in the to connection becomes identical to the from connection |
static void |
synchronizeTableFullOneWay(JdbcUtil.SyncDescriptor syncDescriptor,
org.apache.log4j.Logger log4j)
Insert, update or delete record so that the table in the to connection becomes identical to the from connection |
static boolean |
tableExists(java.sql.Connection connection,
java.lang.String tableName)
Check if a table exists |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String SOURCECODE_VERSION
public static final java.lang.String[] EMPTY_STRING_ARRAY
| Constructor Detail |
|---|
public JdbcUtil()
| Method Detail |
|---|
public static java.lang.String buildSqlSelectAllStatement(java.lang.String tablename,
java.lang.String[] fields,
java.lang.String[] keys,
java.lang.String whereclause)
tableName - fields - keys - whereclause -
public static java.lang.String buildSqlSelectAllStatement(java.lang.String tablename,
java.lang.String[] fields,
java.lang.String[] keys)
public static java.lang.String buildSqlSelectStatement(java.lang.String tablename,
java.lang.String[] fields,
java.lang.String[] keys)
tableName - fields - keys -
public static java.lang.String buildSqlSelectExistsStatement(java.lang.String tablename,
java.lang.String[] keys,
java.lang.String whereclause)
tableName - keys -
public static java.lang.String buildSqlSelectExistsStatement(java.lang.String tablename,
java.lang.String[] keys)
public static java.lang.String buildSqlInsertStatement(java.lang.String tablename,
java.lang.String[] fields,
java.lang.String[] keys)
tableName - fields - keys -
public static java.lang.String buildSqlUpdateStatement(java.lang.String tablename,
java.lang.String[] fields,
java.lang.String[] keys)
tableName - fields - keys -
public static java.lang.String buildSqlDeleteStatement(java.lang.String tablename,
java.lang.String[] keys)
tableName - keys -
public static java.lang.String buildSqlSelectChangedStatement(java.lang.String tablename,
java.lang.String[] fields,
java.lang.String[] keys)
tableName - fields - keys - public static java.sql.Connection close(java.sql.Connection c)
c - public static java.sql.Statement close(java.sql.Statement c)
c - public static java.sql.PreparedStatement close(java.sql.PreparedStatement c)
c - public static java.sql.ResultSet close(java.sql.ResultSet c)
c -
public static int execute(java.sql.Connection connection,
java.lang.String sql)
throws java.sql.SQLException
connection - sql -
java.sql.SQLException
public static int execute(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object... parameters)
throws java.sql.SQLException
connection - sql -
java.sql.SQLException
public static int execute(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static int execute(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
throws java.sql.SQLException
connection - sql -
java.sql.SQLException
public static int execute(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static int execute(java.sql.PreparedStatement preparedStatement)
throws java.sql.SQLException
java.sql.SQLException
public static int execute(java.sql.Connection connection,
SqlBuilder sqlBuilder)
throws java.sql.SQLException
java.sql.SQLExceptionpublic static void rollback(java.sql.Connection connection)
connection - public static void commit(java.sql.Connection connection)
connection -
public static boolean hasAtLeastOneRecord(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object... parameters)
throws java.sql.SQLException
connection - sql - parameters -
java.sql.SQLException
public static boolean hasAtLeastOneRecord(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static boolean hasAtLeastOneRecord(java.sql.Connection connection,
java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLException
public static boolean hasAtLeastOneRecord(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
throws java.sql.SQLException
preparedStatement - parameters -
java.sql.SQLException
public static boolean hasAtLeastOneRecord(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static boolean hasAtLeastOneRecord(java.sql.PreparedStatement preparedStatement)
throws java.sql.SQLException
java.sql.SQLException
public static boolean hasAtLeastOneRecord(java.sql.Connection connection,
SqlBuilder sqlBuilder)
throws java.sql.SQLException
java.sql.SQLException
public static boolean hasEnoughRecords(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters,
int numberOfRecords)
throws java.sql.SQLException
connection - sql - parameters -
java.sql.SQLException
public static boolean hasEnoughRecords(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static boolean hasEnoughRecords(java.sql.Connection connection,
java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLException
public static boolean hasEnoughRecords(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters,
int numberOfRecords)
throws java.sql.SQLException
preparedStatement - parameters - numberOfRecords -
java.sql.SQLException
public static boolean hasEnoughRecords(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static boolean hasEnoughRecords(java.sql.PreparedStatement preparedStatement)
throws java.sql.SQLException
java.sql.SQLException
public static boolean hasEnoughRecords(java.sql.Connection connection,
SqlBuilder sqlBuilder)
throws java.sql.SQLException
java.sql.SQLException
public static boolean tableExists(java.sql.Connection connection,
java.lang.String tableName)
connection - tableName -
public static java.lang.Object query(java.sql.Connection connection,
java.lang.String sql)
throws java.sql.SQLException
connection - sql -
java.sql.SQLException
public static java.lang.Object selectOneRowOneField(java.sql.Connection connection,
java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLException
public static java.lang.Object query(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
throws java.sql.SQLException
connection - sql - parameters -
java.sql.SQLException
public static java.lang.Object selectOneRowOneField(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object... parameters)
throws java.sql.SQLException
java.sql.SQLException
public static java.lang.Object query(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
throws java.sql.SQLException
connection - preparedStatement - parameters -
java.sql.SQLException
public static java.lang.Object selectOneRowOneField(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
throws java.sql.SQLException
java.sql.SQLException
public static java.lang.Object selectOneRowOneField(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static java.lang.Object selectOneRowOneField(java.sql.PreparedStatement preparedStatement)
throws java.sql.SQLException
java.sql.SQLException
public static java.lang.Object selectOneRowOneField(java.sql.Connection connection,
SqlBuilder sqlBuilder)
throws java.sql.SQLException
java.sql.SQLException
public static java.util.List queryAsList(java.sql.Connection connection,
java.lang.String sql)
throws java.sql.SQLException
connection - sql -
java.sql.SQLException
public static java.util.List selectManyRowsFirstField(java.sql.Connection connection,
java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLException
public static java.util.List queryAsList(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
throws java.sql.SQLException
connection - sql - parameters -
java.sql.SQLException
public static java.util.List selectManyRowsFirstField(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
throws java.sql.SQLException
java.sql.SQLException
public static java.util.List selectManyRowsFirstField(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static java.util.List queryAsList(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
throws java.sql.SQLException
connection - preparedStatement - parameters -
java.sql.SQLException
public static java.util.List selectManyRowsFirstField(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
throws java.sql.SQLException
java.sql.SQLException
public static java.util.List selectManyRowsFirstField(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static java.util.List selectManyRowsFirstField(java.sql.PreparedStatement preparedStatement)
throws java.sql.SQLException
java.sql.SQLException
public static java.util.List selectManyRowsFirstField(java.sql.Connection connection,
SqlBuilder sqlBuilder)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcMap queryAsMap(java.sql.Connection connection,
java.lang.String sql)
throws java.sql.SQLException
connection - sql -
java.sql.SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(java.sql.Connection connection,
java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcMap queryAsMap(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
throws java.sql.SQLException
connection - sql -
java.sql.SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcMap queryAsMap(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
throws java.sql.SQLException
connection - preparedStatement - parameters -
java.sql.SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(java.sql.PreparedStatement preparedStatement)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(java.sql.Connection connection,
SqlBuilder sqlBuilder)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcList queryAsListOfMaps(java.sql.Connection connection,
java.lang.String sql)
throws java.sql.SQLException
connection - sql -
java.sql.SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(java.sql.Connection connection,
java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcList queryAsListOfMaps(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
throws java.sql.SQLException
connection - sql - parameters -
java.sql.SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcList queryAsListOfMaps(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
throws java.sql.SQLException
connection - preparedStatement - parameters -
java.sql.SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(java.sql.PreparedStatement preparedStatement)
throws java.sql.SQLException
java.sql.SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(java.sql.Connection connection,
SqlBuilder sqlBuilder)
throws java.sql.SQLException
java.sql.SQLException
public static java.util.Map queryAsKeyValueMap(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
throws java.sql.SQLException
connection - sql - parameters -
java.sql.SQLException
public static java.util.Map selectManyRowsFirstTwoFieldsAsKeyValueMap(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] parameters)
throws java.sql.SQLException
java.sql.SQLException
public static java.util.Map selectManyRowsFirstTwoFieldsAsKeyValueMap(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static java.util.Map queryAsKeyValueMap(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
throws java.sql.SQLException
connection - preparedStatement - parameters -
java.sql.SQLException
public static java.util.Map selectManyRowsFirstTwoFieldsAsKeyValueMap(java.sql.PreparedStatement preparedStatement,
java.lang.Object[] parameters)
throws java.sql.SQLException
java.sql.SQLException
public static java.util.Map selectManyRowsFirstTwoFieldsAsKeyValueMap(java.sql.PreparedStatement preparedStatement,
java.lang.Object parameter)
throws java.sql.SQLException
java.sql.SQLException
public static java.util.Map selectManyRowsFirstTwoFieldsAsKeyValueMap(java.sql.PreparedStatement preparedStatement)
throws java.sql.SQLException
java.sql.SQLException
public static java.util.Map selectManyRowsFirstTwoFieldsAsKeyValueMap(java.sql.Connection connection,
SqlBuilder sqlBuilder)
throws java.sql.SQLException
java.sql.SQLException
public static void setParameters(java.sql.PreparedStatement preparedStatement,
java.lang.Object... parameters)
throws java.sql.SQLException
java.sql.SQLExceptionpublic static java.lang.Object sanatizeParameter(java.lang.Object p)
public static void synchronizeTableFullOneWay(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String tablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws java.sql.SQLException
fromConnection - toConnection - tablename - keys - fields - log4j -
java.sql.SQLException
public static void synchronizeTableFullOneWay(java.sql.Connection fromConnection,
java.lang.String fromTablename,
java.lang.String[] fromKeys,
java.lang.String[] fromFields,
java.sql.Connection toConnection,
java.lang.String toTablename,
java.lang.String[] toKeys,
java.lang.String[] toFields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws java.sql.SQLException
fromConnection - fromTablename - fromKeys - fromFields - toConnection - toTablename - toKeys - toFields - commitEvery - log4j -
java.sql.SQLException
public static void synchronizeTableFullOneWay(JdbcUtil.SyncDescriptor syncDescriptor,
org.apache.log4j.Logger log4j)
throws java.sql.SQLException
syncDescriptor - log4j -
java.sql.SQLException
public static void synchronizeTableFullOneWay_Insert(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String tablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws java.sql.SQLException
fromConnection - toConnection - tablename - keys - fields - log4j -
java.sql.SQLException
public static void synchronizeTableFullOneWay_Insert(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String fromTablename,
java.lang.String toTablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws java.sql.SQLException
fromConnection - toConnection - fromTablename - toTablename - keys - fields - commitEvery - log4j -
java.sql.SQLException
public static void synchronizeTableFullOneWay_Copy(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String fromTablename,
java.lang.String toTablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j,
JdbcUtil.Preprocess preprocess)
throws java.sql.SQLException
fromConnection - toConnection - fromTablename - toTablename - keys - fields - commitEvery - log4j -
java.sql.SQLException
public static void synchronizeTableFullOneWay_Insert(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String fromTablename,
java.lang.String toTablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j,
JdbcUtil.Preprocess preprocess)
throws java.sql.SQLException
fromConnection - toConnection - fromTablename - toTablename - keys - fields - commitEvery - log4j -
java.sql.SQLException
public static void synchronizeTableFullOneWay_InsertUpdate(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String tablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws java.sql.SQLException
fromConnection - toConnection - tablename - keys - fields - log4j -
java.sql.SQLException - TODO: return a list of PK tuples to simplify delete
public static void synchronizeTableFullOneWay_InsertUpdate(java.sql.Connection fromConnection,
java.lang.String fromTablename,
java.lang.String[] fromKeys,
java.lang.String[] fromFields,
java.sql.Connection toConnection,
java.lang.String toTablename,
java.lang.String[] toKeys,
java.lang.String[] toFields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws java.sql.SQLException
fromConnection - fromTablename - fromKeys - fromFields - toConnection - toTablename - toKeys - toFields - commitEvery - log4j -
java.sql.SQLException
public static void synchronizeTableFullOneWay_InsertUpdate(JdbcUtil.SyncDescriptor syncDescriptor,
org.apache.log4j.Logger log4j)
throws java.sql.SQLException
syncDescriptor - log4j -
java.sql.SQLException
public static void synchronizeTableFullOneWay_Delete(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String tablename,
java.lang.String[] keys,
java.lang.String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws java.sql.SQLException
fromConnection - toConnection - tablename - keys - fields - log4j -
java.sql.SQLException
public static void synchronizeTableFullOneWay_Delete(java.sql.Connection fromConnection,
java.lang.String fromTablename,
java.lang.String[] fromKeys,
java.lang.String[] fromFields,
java.sql.Connection toConnection,
java.lang.String toTablename,
java.lang.String[] toKeys,
java.lang.String[] toFields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws java.sql.SQLException
fromConnection - toConnection - tablename - keys - fields - commitEvery - log4j -
java.sql.SQLException
public static void synchronizeTableFullOneWay_Delete(JdbcUtil.SyncDescriptor syncDescriptor,
org.apache.log4j.Logger log4j)
throws java.sql.SQLException
syncDescriptor - log4j -
java.sql.SQLException
public static void synchronizeTableFullOneWay(java.sql.Connection fromConnection,
java.sql.Connection toConnection,
java.lang.String fromSchemaName,
java.lang.String fromTablename,
int commitEvery,
org.apache.log4j.Logger log4j)
throws java.sql.SQLException
fromConnection - toConnection - fromSchemaName - fromTablename - commitEvery - log4j -
java.sql.SQLException
public static java.lang.Number getNextValueFromSequenceTable(java.sql.Connection connection,
java.lang.String tableName,
java.lang.String idColumnName,
java.lang.String id,
java.lang.String valueColumnName,
int increment)
throws java.sql.SQLException
connection - this connection should have auto commit set to false, otherwise there is a small gap where things may go wrongtableName - idColumnName - id - valueColumnName - increment -
java.sql.SQLException
public static java.lang.Number getNextValueFromSequenceTable(java.sql.Connection connection,
java.lang.String tableName,
java.lang.String idColumnName,
java.lang.String id,
java.lang.String valueColumnName)
throws java.sql.SQLException
connection - tableName - idColumnName - id - valueColumnName -
java.sql.SQLException
public static java.lang.Number getNextValueFromSequenceTable(java.sql.Connection connection,
java.lang.String id)
throws java.sql.SQLException
connection - id -
java.sql.SQLException
public static java.lang.Number getNextValueFromSequenceTableAndCheck(java.sql.Connection connection,
java.lang.String tableName,
java.lang.String idColumnName,
java.lang.String id,
java.lang.String valueColumnName,
java.lang.String sql,
int maxTries)
throws java.sql.SQLException
connection - tableName - sequence table nameidColumnName - sequence table id column nameid - the id stored in the id columnvalueColumnName - sequence table value column namesql - the SQL that validates is the number already is used a a PKmaxTries - number of tries to get a PK
java.sql.SQLException
public static int determineColumnType(java.sql.Connection connection,
java.lang.String tableAndColumnName)
public static int determineColumnType(java.sql.Connection connection,
java.lang.String tableName,
java.lang.String columnName)
public static boolean isColumnTypeNumber(int type)
public static boolean isColumnTypeDateOrTime(int type)
public static boolean isColumnTypeString(int type)
public static java.lang.Object getDefaultValueFor(int lType)
lType -
public static int getFieldLength(java.sql.Connection connection,
java.lang.String tablename,
java.lang.String columnname)
connection - tablename - columnname -
public static int getFieldLength(java.sql.Connection connection,
java.lang.String tablenamePlusColumnname)
connection - tablenamePlusColumnname - tablename.columnname
public static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||