|
||||||||||
| 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 String[] |
EMPTY_STRING_ARRAY
|
static String |
SOURCECODE_VERSION
Standard variable for determining version of a class file. |
| Constructor Summary | |
|---|---|
JdbcUtil()
|
|
| Method Summary | |
|---|---|
static String |
buildSqlDeleteStatement(String tablename,
String[] keys)
Build the SQL statement that checks if a certain record exists select 1 from table where key=? |
static String |
buildSqlInsertStatement(String tablename,
String[] fields,
String[] keys)
Build an insert statement with the same parameter list as the update statement would have. |
static String |
buildSqlSelectAllStatement(String tablename,
String[] fields,
String[] keys)
|
static String |
buildSqlSelectAllStatement(String tablename,
String[] fields,
String[] keys,
String whereclause)
Build the SQL statement that selects the specified fields of one record select field, ... from table Optionally a where clause can be specified |
static String |
buildSqlSelectChangedStatement(String tablename,
String[] fields,
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<>? |
static String |
buildSqlSelectExistsStatement(String tablename,
String[] keys)
|
static String |
buildSqlSelectExistsStatement(String tablename,
String[] keys,
String whereclause)
Build the SQL statement that checks if a certain record exists select 1 from table where key=? |
static String |
buildSqlSelectStatement(String tablename,
String[] fields,
String[] keys)
Build the SQL statement that selects the specified fields of one record select field, ... from table where key=? |
static String |
buildSqlUpdateStatement(String tablename,
String[] fields,
String[] keys)
Build an update statement with the same parameter list as the insert statement would have. |
static Connection |
close(Connection c)
Close and wrap the possible but highly unlikely exception in a RuntimeException |
static PreparedStatement |
close(PreparedStatement c)
Close and wrap the possible but highly unlikely exception in a RuntimeException |
static ResultSet |
close(ResultSet c)
Close and wrap the possible but highly unlikely exception in a RuntimeException |
static Statement |
close(Statement c)
Close and wrap the possible but highly unlikely exception in a RuntimeException |
static void |
commit(Connection connection)
Commit but throw a runtime exception instead of a SQLExeception. |
static int |
determineColumnType(Connection connection,
String tableAndColumnName)
Return the java.sql.Types for a column NOTE: it may be smart to cache the results |
static int |
determineColumnType(Connection connection,
String tableName,
String columnName)
Return the java.sql.Types for a column NOTE: it may be smart to cache the results |
static int |
execute(Connection connection,
SqlBuilder sqlBuilder)
|
static int |
execute(Connection connection,
String sql)
Execute a single SQL |
static int |
execute(Connection connection,
String sql,
Object... parameters)
Execute a single SQL with parameters |
static int |
execute(Connection connection,
String sql,
Object parameter)
|
static int |
execute(PreparedStatement preparedStatement)
|
static int |
execute(PreparedStatement preparedStatement,
Object parameter)
|
static int |
execute(PreparedStatement preparedStatement,
Object[] parameters)
Execute a single SQL with parameters |
static Object |
getDefaultValueFor(int lType)
Return a default value for all java.sql.Types |
static int |
getFieldLength(Connection connection,
String tablenamePlusColumnname)
Determines the length of a field using metadata |
static int |
getFieldLength(Connection connection,
String tablename,
String columnname)
Determines the length of a field using metadata |
static Number |
getNextValueFromSequenceTable(Connection connection,
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 Number |
getNextValueFromSequenceTable(Connection connection,
String tableName,
String idColumnName,
String id,
String valueColumnName)
Get a single value from a sequence table |
static Number |
getNextValueFromSequenceTable(Connection connection,
String tableName,
String idColumnName,
String id,
String valueColumnName,
int increment)
Get a value block from a sequence table |
static Number |
getNextValueFromSequenceTableAndCheck(Connection connection,
String tableName,
String idColumnName,
String id,
String valueColumnName,
String sql,
int maxTries)
Get a single value from a sequence table |
static boolean |
hasAtLeastOneRecord(Connection connection,
SqlBuilder sqlBuilder)
|
static boolean |
hasAtLeastOneRecord(Connection connection,
String sql)
|
static boolean |
hasAtLeastOneRecord(Connection connection,
String sql,
Object... parameters)
Check to see if the resultset has enough records |
static boolean |
hasAtLeastOneRecord(Connection connection,
String sql,
Object parameter)
|
static boolean |
hasAtLeastOneRecord(PreparedStatement preparedStatement)
|
static boolean |
hasAtLeastOneRecord(PreparedStatement preparedStatement,
Object parameter)
|
static boolean |
hasAtLeastOneRecord(PreparedStatement preparedStatement,
Object[] parameters)
Check to see if the resultset has enough records |
static boolean |
hasEnoughRecords(Connection connection,
SqlBuilder sqlBuilder)
|
static boolean |
hasEnoughRecords(Connection connection,
String sql)
|
static boolean |
hasEnoughRecords(Connection connection,
String sql,
Object parameter)
|
static boolean |
hasEnoughRecords(Connection connection,
String sql,
Object[] parameters,
int numberOfRecords)
Check to see if the resultset has enough records |
static boolean |
hasEnoughRecords(PreparedStatement preparedStatement)
|
static boolean |
hasEnoughRecords(PreparedStatement preparedStatement,
Object parameter)
|
static boolean |
hasEnoughRecords(PreparedStatement preparedStatement,
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(String[] args)
Some quick unit tests |
static Object |
query(Connection connection,
String sql)
Fetch one row, one field |
static Object |
query(Connection connection,
String sql,
Object[] parameters)
Fetch one row, one field |
static Object |
query(PreparedStatement preparedStatement,
Object[] parameters)
Fetch one row, one field |
static Map |
queryAsKeyValueMap(Connection connection,
String sql,
Object[] parameters)
Fetch key value pairs (1st first is key, 2nd is value, rest is ignored) |
static Map |
queryAsKeyValueMap(PreparedStatement preparedStatement,
Object[] parameters)
Fetch key value pairs (1st first is key, 2nd is value, rest is ignored) |
static List |
queryAsList(Connection connection,
String sql)
Fetch multiple rows, one field |
static List |
queryAsList(Connection connection,
String sql,
Object[] parameters)
Fetch multiple rows, one field |
static List |
queryAsList(PreparedStatement preparedStatement,
Object[] parameters)
Fetch multiple rows, one field |
static JdbcUtil.JdbcList |
queryAsListOfMaps(Connection connection,
String sql)
Fetch multiple rows, multiple fields |
static JdbcUtil.JdbcList |
queryAsListOfMaps(Connection connection,
String sql,
Object[] parameters)
Fetch multiple rows, multiple fields |
static JdbcUtil.JdbcList |
queryAsListOfMaps(PreparedStatement preparedStatement,
Object[] parameters)
Fetch multiple rows, multiple fields |
static JdbcUtil.JdbcMap |
queryAsMap(Connection connection,
String sql)
Fetch one row, multiple fields |
static JdbcUtil.JdbcMap |
queryAsMap(Connection connection,
String sql,
Object[] parameters)
Fetch one row, multiple fields |
static JdbcUtil.JdbcMap |
queryAsMap(PreparedStatement preparedStatement,
Object[] parameters)
Fetch one row, multiple fields |
static void |
rollback(Connection connection)
Commit but throw a runtime exception instead of a SQLExeception. |
static Object |
sanatizeParameter(Object p)
try to convert parameters to something JDBC will accept, like Calendar to java.sql.Date |
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(Connection connection,
SqlBuilder sqlBuilder)
|
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(Connection connection,
String sql)
|
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(Connection connection,
String sql,
Object parameter)
|
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(Connection connection,
String sql,
Object[] parameters)
|
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(PreparedStatement preparedStatement)
|
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(PreparedStatement preparedStatement,
Object parameter)
|
static JdbcUtil.JdbcList |
selectManyRowsAllFieldsAsListOfMap(PreparedStatement preparedStatement,
Object[] parameters)
|
static List |
selectManyRowsFirstField(Connection connection,
SqlBuilder sqlBuilder)
|
static List |
selectManyRowsFirstField(Connection connection,
String sql)
|
static List |
selectManyRowsFirstField(Connection connection,
String sql,
Object parameter)
|
static List |
selectManyRowsFirstField(Connection connection,
String sql,
Object[] parameters)
|
static List |
selectManyRowsFirstField(PreparedStatement preparedStatement)
|
static List |
selectManyRowsFirstField(PreparedStatement preparedStatement,
Object parameter)
|
static List |
selectManyRowsFirstField(PreparedStatement preparedStatement,
Object[] parameters)
|
static Map |
selectManyRowsFirstTwoFieldsAsKeyValueMap(Connection connection,
SqlBuilder sqlBuilder)
|
static Map |
selectManyRowsFirstTwoFieldsAsKeyValueMap(Connection connection,
String sql,
Object parameter)
|
static Map |
selectManyRowsFirstTwoFieldsAsKeyValueMap(Connection connection,
String sql,
Object[] parameters)
|
static Map |
selectManyRowsFirstTwoFieldsAsKeyValueMap(PreparedStatement preparedStatement)
|
static Map |
selectManyRowsFirstTwoFieldsAsKeyValueMap(PreparedStatement preparedStatement,
Object parameter)
|
static Map |
selectManyRowsFirstTwoFieldsAsKeyValueMap(PreparedStatement preparedStatement,
Object[] parameters)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(Connection connection,
SqlBuilder sqlBuilder)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(Connection connection,
String sql)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(Connection connection,
String sql,
Object parameter)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(Connection connection,
String sql,
Object[] parameters)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(PreparedStatement preparedStatement)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(PreparedStatement preparedStatement,
Object parameter)
|
static JdbcUtil.JdbcMap |
selectOneRowAllFields(PreparedStatement preparedStatement,
Object[] parameters)
|
static Object |
selectOneRowOneField(Connection connection,
SqlBuilder sqlBuilder)
|
static Object |
selectOneRowOneField(Connection connection,
String sql)
|
static Object |
selectOneRowOneField(Connection connection,
String sql,
Object... parameters)
|
static Object |
selectOneRowOneField(PreparedStatement preparedStatement)
|
static Object |
selectOneRowOneField(PreparedStatement preparedStatement,
Object parameter)
|
static Object |
selectOneRowOneField(PreparedStatement preparedStatement,
Object[] parameters)
|
static void |
setParameters(PreparedStatement preparedStatement,
Object... parameters)
set parameters to a prepared statement |
static void |
synchronizeTableFullOneWay_Copy(Connection fromConnection,
Connection toConnection,
String fromTablename,
String toTablename,
String[] keys,
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(Connection fromConnection,
Connection toConnection,
String tablename,
String[] keys,
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(Connection fromConnection,
String fromTablename,
String[] fromKeys,
String[] fromFields,
Connection toConnection,
String toTablename,
String[] toKeys,
String[] toFields,
int commitEvery,
boolean logExceptionButContinue,
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(Connection fromConnection,
Connection toConnection,
String tablename,
String[] keys,
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(Connection fromConnection,
Connection toConnection,
String fromTablename,
String toTablename,
String[] keys,
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(Connection fromConnection,
Connection toConnection,
String fromTablename,
String toTablename,
String[] keys,
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(Connection fromConnection,
Connection toConnection,
String tablename,
String[] keys,
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(Connection fromConnection,
String fromTablename,
String[] fromKeys,
String[] fromFields,
Connection toConnection,
String toTablename,
String[] toKeys,
String[] toFields,
int commitEvery,
boolean logExceptionButContinue,
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(Connection fromConnection,
Connection toConnection,
String tablename,
String[] keys,
String[] fields,
int commitEvery,
boolean logExceptionButContinue,
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(Connection fromConnection,
Connection toConnection,
String tablename,
String[] keys,
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(Connection fromConnection,
Connection toConnection,
String fromSchemaName,
String fromTablename,
int commitEvery,
org.apache.log4j.Logger log4j)
Sync a table with all fields |
static void |
synchronizeTableFullOneWay(Connection fromConnection,
String fromTablename,
String[] fromKeys,
String[] fromFields,
Connection toConnection,
String toTablename,
String[] toKeys,
String[] toFields,
int commitEvery,
boolean logExceptionButContinue,
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(Connection fromConnection,
String fromTablename,
String[] fromKeys,
String[] fromFields,
Connection toConnection,
String toTablename,
String[] toKeys,
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(Connection connection,
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 String SOURCECODE_VERSION
public static final String[] EMPTY_STRING_ARRAY
| Constructor Detail |
|---|
public JdbcUtil()
| Method Detail |
|---|
public static String buildSqlSelectAllStatement(String tablename,
String[] fields,
String[] keys,
String whereclause)
tableName - fields - keys - whereclause -
public static String buildSqlSelectAllStatement(String tablename,
String[] fields,
String[] keys)
public static String buildSqlSelectStatement(String tablename,
String[] fields,
String[] keys)
tableName - fields - keys -
public static String buildSqlSelectExistsStatement(String tablename,
String[] keys,
String whereclause)
tableName - keys -
public static String buildSqlSelectExistsStatement(String tablename,
String[] keys)
public static String buildSqlInsertStatement(String tablename,
String[] fields,
String[] keys)
tableName - fields - keys -
public static String buildSqlUpdateStatement(String tablename,
String[] fields,
String[] keys)
tableName - fields - keys -
public static String buildSqlDeleteStatement(String tablename,
String[] keys)
tableName - keys -
public static String buildSqlSelectChangedStatement(String tablename,
String[] fields,
String[] keys)
tableName - fields - keys - public static Connection close(Connection c)
c - public static Statement close(Statement c)
c - public static PreparedStatement close(PreparedStatement c)
c - public static ResultSet close(ResultSet c)
c -
public static int execute(Connection connection,
String sql)
throws SQLException
connection - sql -
SQLException
public static int execute(Connection connection,
String sql,
Object... parameters)
throws SQLException
connection - sql -
SQLException
public static int execute(Connection connection,
String sql,
Object parameter)
throws SQLException
SQLException
public static int execute(PreparedStatement preparedStatement,
Object[] parameters)
throws SQLException
connection - sql -
SQLException
public static int execute(PreparedStatement preparedStatement,
Object parameter)
throws SQLException
SQLException
public static int execute(PreparedStatement preparedStatement)
throws SQLException
SQLException
public static int execute(Connection connection,
SqlBuilder sqlBuilder)
throws SQLException
SQLExceptionpublic static void rollback(Connection connection)
connection - public static void commit(Connection connection)
connection -
public static boolean hasAtLeastOneRecord(Connection connection,
String sql,
Object... parameters)
throws SQLException
connection - sql - parameters -
SQLException
public static boolean hasAtLeastOneRecord(Connection connection,
String sql,
Object parameter)
throws SQLException
SQLException
public static boolean hasAtLeastOneRecord(Connection connection,
String sql)
throws SQLException
SQLException
public static boolean hasAtLeastOneRecord(PreparedStatement preparedStatement,
Object[] parameters)
throws SQLException
preparedStatement - parameters -
SQLException
public static boolean hasAtLeastOneRecord(PreparedStatement preparedStatement,
Object parameter)
throws SQLException
SQLException
public static boolean hasAtLeastOneRecord(PreparedStatement preparedStatement)
throws SQLException
SQLException
public static boolean hasAtLeastOneRecord(Connection connection,
SqlBuilder sqlBuilder)
throws SQLException
SQLException
public static boolean hasEnoughRecords(Connection connection,
String sql,
Object[] parameters,
int numberOfRecords)
throws SQLException
connection - sql - parameters -
SQLException
public static boolean hasEnoughRecords(Connection connection,
String sql,
Object parameter)
throws SQLException
SQLException
public static boolean hasEnoughRecords(Connection connection,
String sql)
throws SQLException
SQLException
public static boolean hasEnoughRecords(PreparedStatement preparedStatement,
Object[] parameters,
int numberOfRecords)
throws SQLException
preparedStatement - parameters - numberOfRecords -
SQLException
public static boolean hasEnoughRecords(PreparedStatement preparedStatement,
Object parameter)
throws SQLException
SQLException
public static boolean hasEnoughRecords(PreparedStatement preparedStatement)
throws SQLException
SQLException
public static boolean hasEnoughRecords(Connection connection,
SqlBuilder sqlBuilder)
throws SQLException
SQLException
public static boolean tableExists(Connection connection,
String tableName)
connection - tableName -
public static Object query(Connection connection,
String sql)
throws SQLException
connection - sql -
SQLException
public static Object selectOneRowOneField(Connection connection,
String sql)
throws SQLException
SQLException
public static Object query(Connection connection,
String sql,
Object[] parameters)
throws SQLException
connection - sql - parameters -
SQLException
public static Object selectOneRowOneField(Connection connection,
String sql,
Object... parameters)
throws SQLException
SQLException
public static Object query(PreparedStatement preparedStatement,
Object[] parameters)
throws SQLException
connection - preparedStatement - parameters -
SQLException
public static Object selectOneRowOneField(PreparedStatement preparedStatement,
Object[] parameters)
throws SQLException
SQLException
public static Object selectOneRowOneField(PreparedStatement preparedStatement,
Object parameter)
throws SQLException
SQLException
public static Object selectOneRowOneField(PreparedStatement preparedStatement)
throws SQLException
SQLException
public static Object selectOneRowOneField(Connection connection,
SqlBuilder sqlBuilder)
throws SQLException
SQLException
public static List queryAsList(Connection connection,
String sql)
throws SQLException
connection - sql -
SQLException
public static List selectManyRowsFirstField(Connection connection,
String sql)
throws SQLException
SQLException
public static List queryAsList(Connection connection,
String sql,
Object[] parameters)
throws SQLException
connection - sql - parameters -
SQLException
public static List selectManyRowsFirstField(Connection connection,
String sql,
Object[] parameters)
throws SQLException
SQLException
public static List selectManyRowsFirstField(Connection connection,
String sql,
Object parameter)
throws SQLException
SQLException
public static List queryAsList(PreparedStatement preparedStatement,
Object[] parameters)
throws SQLException
connection - preparedStatement - parameters -
SQLException
public static List selectManyRowsFirstField(PreparedStatement preparedStatement,
Object[] parameters)
throws SQLException
SQLException
public static List selectManyRowsFirstField(PreparedStatement preparedStatement,
Object parameter)
throws SQLException
SQLException
public static List selectManyRowsFirstField(PreparedStatement preparedStatement)
throws SQLException
SQLException
public static List selectManyRowsFirstField(Connection connection,
SqlBuilder sqlBuilder)
throws SQLException
SQLException
public static JdbcUtil.JdbcMap queryAsMap(Connection connection,
String sql)
throws SQLException
connection - sql -
SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(Connection connection,
String sql)
throws SQLException
SQLException
public static JdbcUtil.JdbcMap queryAsMap(Connection connection,
String sql,
Object[] parameters)
throws SQLException
connection - sql -
SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(Connection connection,
String sql,
Object[] parameters)
throws SQLException
SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(Connection connection,
String sql,
Object parameter)
throws SQLException
SQLException
public static JdbcUtil.JdbcMap queryAsMap(PreparedStatement preparedStatement,
Object[] parameters)
throws SQLException
connection - preparedStatement - parameters -
SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(PreparedStatement preparedStatement,
Object[] parameters)
throws SQLException
SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(PreparedStatement preparedStatement,
Object parameter)
throws SQLException
SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(PreparedStatement preparedStatement)
throws SQLException
SQLException
public static JdbcUtil.JdbcMap selectOneRowAllFields(Connection connection,
SqlBuilder sqlBuilder)
throws SQLException
SQLException
public static JdbcUtil.JdbcList queryAsListOfMaps(Connection connection,
String sql)
throws SQLException
connection - sql -
SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(Connection connection,
String sql)
throws SQLException
SQLException
public static JdbcUtil.JdbcList queryAsListOfMaps(Connection connection,
String sql,
Object[] parameters)
throws SQLException
connection - sql - parameters -
SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(Connection connection,
String sql,
Object[] parameters)
throws SQLException
SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(Connection connection,
String sql,
Object parameter)
throws SQLException
SQLException
public static JdbcUtil.JdbcList queryAsListOfMaps(PreparedStatement preparedStatement,
Object[] parameters)
throws SQLException
connection - preparedStatement - parameters -
SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(PreparedStatement preparedStatement,
Object[] parameters)
throws SQLException
SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(PreparedStatement preparedStatement,
Object parameter)
throws SQLException
SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(PreparedStatement preparedStatement)
throws SQLException
SQLException
public static JdbcUtil.JdbcList selectManyRowsAllFieldsAsListOfMap(Connection connection,
SqlBuilder sqlBuilder)
throws SQLException
SQLException
public static Map queryAsKeyValueMap(Connection connection,
String sql,
Object[] parameters)
throws SQLException
connection - sql - parameters -
SQLException
public static Map selectManyRowsFirstTwoFieldsAsKeyValueMap(Connection connection,
String sql,
Object[] parameters)
throws SQLException
SQLException
public static Map selectManyRowsFirstTwoFieldsAsKeyValueMap(Connection connection,
String sql,
Object parameter)
throws SQLException
SQLException
public static Map queryAsKeyValueMap(PreparedStatement preparedStatement,
Object[] parameters)
throws SQLException
connection - preparedStatement - parameters -
SQLException
public static Map selectManyRowsFirstTwoFieldsAsKeyValueMap(PreparedStatement preparedStatement,
Object[] parameters)
throws SQLException
SQLException
public static Map selectManyRowsFirstTwoFieldsAsKeyValueMap(PreparedStatement preparedStatement,
Object parameter)
throws SQLException
SQLException
public static Map selectManyRowsFirstTwoFieldsAsKeyValueMap(PreparedStatement preparedStatement)
throws SQLException
SQLException
public static Map selectManyRowsFirstTwoFieldsAsKeyValueMap(Connection connection,
SqlBuilder sqlBuilder)
throws SQLException
SQLException
public static void setParameters(PreparedStatement preparedStatement,
Object... parameters)
throws SQLException
SQLExceptionpublic static Object sanatizeParameter(Object p)
public static void synchronizeTableFullOneWay(Connection fromConnection,
Connection toConnection,
String tablename,
String[] keys,
String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws SQLException
fromConnection - toConnection - tablename - keys - fields - log4j -
SQLException
public static void synchronizeTableFullOneWay(Connection fromConnection,
Connection toConnection,
String tablename,
String[] keys,
String[] fields,
int commitEvery,
boolean logExceptionButContinue,
org.apache.log4j.Logger log4j)
throws SQLException
fromConnection - toConnection - tablename - keys - fields - log4j -
SQLException
public static void synchronizeTableFullOneWay(Connection fromConnection,
String fromTablename,
String[] fromKeys,
String[] fromFields,
Connection toConnection,
String toTablename,
String[] toKeys,
String[] toFields,
int commitEvery,
boolean logExceptionButContinue,
org.apache.log4j.Logger log4j)
throws SQLException
fromConnection - fromTablename - fromKeys - fromFields - toConnection - toTablename - toKeys - toFields - commitEvery - log4j -
SQLException
public static void synchronizeTableFullOneWay(Connection fromConnection,
String fromTablename,
String[] fromKeys,
String[] fromFields,
Connection toConnection,
String toTablename,
String[] toKeys,
String[] toFields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws SQLException
fromConnection - fromTablename - fromKeys - fromFields - toConnection - toTablename - toKeys - toFields - commitEvery - log4j -
SQLException
public static void synchronizeTableFullOneWay(JdbcUtil.SyncDescriptor syncDescriptor,
org.apache.log4j.Logger log4j)
throws SQLException
syncDescriptor - log4j -
SQLException
public static void synchronizeTableFullOneWay_Insert(Connection fromConnection,
Connection toConnection,
String tablename,
String[] keys,
String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws SQLException
fromConnection - toConnection - tablename - keys - fields - log4j -
SQLException
public static void synchronizeTableFullOneWay_Insert(Connection fromConnection,
Connection toConnection,
String fromTablename,
String toTablename,
String[] keys,
String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws SQLException
fromConnection - toConnection - fromTablename - toTablename - keys - fields - commitEvery - log4j -
SQLException
public static void synchronizeTableFullOneWay_Copy(Connection fromConnection,
Connection toConnection,
String fromTablename,
String toTablename,
String[] keys,
String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j,
JdbcUtil.Preprocess preprocess)
throws SQLException
fromConnection - toConnection - fromTablename - toTablename - keys - fields - commitEvery - log4j -
SQLException
public static void synchronizeTableFullOneWay_Insert(Connection fromConnection,
Connection toConnection,
String fromTablename,
String toTablename,
String[] keys,
String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j,
JdbcUtil.Preprocess preprocess)
throws SQLException
fromConnection - toConnection - fromTablename - toTablename - keys - fields - commitEvery - log4j -
SQLException
public static void synchronizeTableFullOneWay_InsertUpdate(Connection fromConnection,
Connection toConnection,
String tablename,
String[] keys,
String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws SQLException
fromConnection - toConnection - tablename - keys - fields - log4j -
SQLException - TODO: return a list of PK tuples to simplify delete
public static void synchronizeTableFullOneWay_InsertUpdate(Connection fromConnection,
String fromTablename,
String[] fromKeys,
String[] fromFields,
Connection toConnection,
String toTablename,
String[] toKeys,
String[] toFields,
int commitEvery,
boolean logExceptionButContinue,
org.apache.log4j.Logger log4j)
throws SQLException
fromConnection - fromTablename - fromKeys - fromFields - toConnection - toTablename - toKeys - toFields - commitEvery - log4j -
SQLException
public static void synchronizeTableFullOneWay_InsertUpdate(JdbcUtil.SyncDescriptor syncDescriptor,
org.apache.log4j.Logger log4j)
throws SQLException
syncDescriptor - log4j -
SQLException
public static void synchronizeTableFullOneWay_Delete(Connection fromConnection,
Connection toConnection,
String tablename,
String[] keys,
String[] fields,
int commitEvery,
org.apache.log4j.Logger log4j)
throws SQLException
fromConnection - toConnection - tablename - keys - fields - log4j -
SQLException
public static void synchronizeTableFullOneWay_Delete(Connection fromConnection,
String fromTablename,
String[] fromKeys,
String[] fromFields,
Connection toConnection,
String toTablename,
String[] toKeys,
String[] toFields,
int commitEvery,
boolean logExceptionButContinue,
org.apache.log4j.Logger log4j)
throws SQLException
fromConnection - toConnection - tablename - keys - fields - commitEvery - log4j -
SQLException
public static void synchronizeTableFullOneWay_Delete(JdbcUtil.SyncDescriptor syncDescriptor,
org.apache.log4j.Logger log4j)
throws SQLException
syncDescriptor - log4j -
SQLException
public static void synchronizeTableFullOneWay(Connection fromConnection,
Connection toConnection,
String fromSchemaName,
String fromTablename,
int commitEvery,
org.apache.log4j.Logger log4j)
throws SQLException
fromConnection - toConnection - fromSchemaName - fromTablename - commitEvery - log4j -
SQLException
public static Number getNextValueFromSequenceTable(Connection connection,
String tableName,
String idColumnName,
String id,
String valueColumnName,
int increment)
throws 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 -
SQLException
public static Number getNextValueFromSequenceTable(Connection connection,
String tableName,
String idColumnName,
String id,
String valueColumnName)
throws SQLException
connection - tableName - idColumnName - id - valueColumnName -
SQLException
public static Number getNextValueFromSequenceTable(Connection connection,
String id)
throws SQLException
connection - id -
SQLException
public static Number getNextValueFromSequenceTableAndCheck(Connection connection,
String tableName,
String idColumnName,
String id,
String valueColumnName,
String sql,
int maxTries)
throws 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
SQLException
public static int determineColumnType(Connection connection,
String tableAndColumnName)
public static int determineColumnType(Connection connection,
String tableName,
String columnName)
public static boolean isColumnTypeNumber(int type)
public static boolean isColumnTypeDateOrTime(int type)
public static boolean isColumnTypeString(int type)
public static Object getDefaultValueFor(int lType)
lType -
public static int getFieldLength(Connection connection,
String tablename,
String columnname)
connection - tablename - columnname -
public static int getFieldLength(Connection connection,
String tablenamePlusColumnname)
connection - tablenamePlusColumnname - tablename.columnname
public static void main(String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||