|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.net4j.db.DBUtil
public final class DBUtil
A utility class with various static factory and convenience methods.
Method Summary | |
---|---|
static Exception |
close(Connection connection)
|
static Exception |
close(ResultSet resultSet)
|
static Exception |
close(Statement statement)
|
static IDBConnectionProvider |
createConnectionProvider(DataSource dataSource)
|
static DataSource |
createDataSource(Map<Object,Object> properties)
|
static DataSource |
createDataSource(Map<Object,Object> properties,
String namespace)
|
static DataSource |
createDataSource(Map<Object,Object> properties,
String namespace,
String driverClassKey)
|
static IDBSchema |
createSchema(String name)
|
static void |
deserializeTable(ExtendedDataInput in,
Connection connection,
IDBTable table,
OMMonitor monitor)
|
static List<Exception> |
dropAllTables(Connection connection,
String dbName)
|
static List<String> |
getAllSchemaTableNames(Connection connection)
|
static List<String> |
getAllSchemaTableNames(DatabaseMetaData metaData)
|
static List<String> |
getAllTableNames(Connection connection,
String dbName)
|
static IDBAdapter |
getDBAdapter(String adapterName)
Can only be used when Eclipse is running. |
static int |
getRowCount(ResultSet resultSet)
Returns the number of rows contained in the given result set. |
static int |
select(Connection connection,
IDBRowHandler rowHandler,
IDBField... fields)
|
static int |
select(Connection connection,
IDBRowHandler rowHandler,
String where,
IDBField... fields)
|
static Object[] |
select(Connection connection,
String where,
IDBField... fields)
|
static int |
selectMaximumInt(Connection connection,
IDBField field,
String... where)
|
static long |
selectMaximumLong(Connection connection,
IDBField field,
String... where)
|
static int |
selectMinimumInt(Connection connection,
IDBField field,
String... where)
|
static long |
selectMinimumLong(Connection connection,
IDBField field,
String... where)
|
static void |
serializeTable(ExtendedDataOutput out,
Connection connection,
IDBTable table,
String tableAlias,
String sqlSuffix)
|
static void |
sqlDump(Connection conn,
String sql)
Deprecated. Should only be used when debugging. |
static void |
sqlDump(IDBConnectionProvider connectionProvider,
String sql)
Deprecated. Should only be used when debugging. |
static String |
trace(String sql)
|
static int |
update(Connection connection,
String sql)
|
static int |
update(PreparedStatement stmt,
boolean exactlyOne)
Execute update on the given prepared statement and handle common cases of return values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
@Deprecated public static void sqlDump(Connection conn, String sql)
@Deprecated public static void sqlDump(IDBConnectionProvider connectionProvider, String sql)
public static IDBSchema createSchema(String name)
public static DataSource createDataSource(Map<Object,Object> properties)
public static DataSource createDataSource(Map<Object,Object> properties, String namespace)
public static DataSource createDataSource(Map<Object,Object> properties, String namespace, String driverClassKey)
public static IDBConnectionProvider createConnectionProvider(DataSource dataSource)
public static IDBAdapter getDBAdapter(String adapterName)
public static Exception close(Connection connection)
public static Exception close(Statement statement)
public static Exception close(ResultSet resultSet)
public static List<String> getAllSchemaTableNames(Connection connection)
public static List<String> getAllSchemaTableNames(DatabaseMetaData metaData)
public static List<String> getAllTableNames(Connection connection, String dbName)
public static List<Exception> dropAllTables(Connection connection, String dbName)
public static int selectMinimumInt(Connection connection, IDBField field, String... where) throws DBException
DBException
public static long selectMinimumLong(Connection connection, IDBField field, String... where) throws DBException
DBException
public static int selectMaximumInt(Connection connection, IDBField field, String... where) throws DBException
DBException
public static long selectMaximumLong(Connection connection, IDBField field, String... where) throws DBException
DBException
public static int update(Connection connection, String sql)
public static int update(PreparedStatement stmt, boolean exactlyOne) throws SQLException
stmt
- the prepared statementexactlyOne
- if true
, the update count is checked to be 1
. Else the update result is only
checked so that the update was successful (i.e. result code != Statement.EXECUTE_FAILED).
PreparedStatement.executeUpdate()
. Can be used
by the caller to perform more advanced checks.
SQLException
- if PreparedStatement.executeUpdate()
throws it.
IllegalStateException
- if the check indicated by excatlyOne
indicates an error.public static int select(Connection connection, IDBRowHandler rowHandler, String where, IDBField... fields) throws DBException
DBException
public static int select(Connection connection, IDBRowHandler rowHandler, IDBField... fields) throws DBException
DBException
public static Object[] select(Connection connection, String where, IDBField... fields) throws DBException
DBException
public static int getRowCount(ResultSet resultSet) throws DBException
The statement
of the result set must have been created with
TYPE_SCROLL_INSENSITIVE
.
DBException
public static void serializeTable(ExtendedDataOutput out, Connection connection, IDBTable table, String tableAlias, String sqlSuffix) throws DBException, IOException
DBException
IOException
public static void deserializeTable(ExtendedDataInput in, Connection connection, IDBTable table, OMMonitor monitor) throws IOException
IOException
public static String trace(String sql)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |