Package org.eclipse.net4j.db
Klasse DBUtil
java.lang.Object
org.eclipse.net4j.db.DBUtil
A utility class with various static factory and convenience methods.
- Autor:
- Eike Stepper
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic interfaceArow handlerwith amethodthat is called once per row deserialized withinDBUtil.deserializeTable().static interfaceCall-back interface with amethodthat is called after a number of table rows have been handled by one of the subtypes of this interface.static interfacestatic interface -
Feldübersicht
Felder -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic intstatic longstatic BatchedStatementbatched(PreparedStatement delegate, int batchSize) static intclearTable(Connection connection, String tableName) static intclearTable(Connection connection, IDBTable table) static Exceptionclose(Connection connection) static Exceptionstatic Exceptionstatic booleancontainsName(Set<String> names, String name, boolean caseSensitive) static IDBSchemacopySchema(IDBSchema source) static IDBConnectionProvidercreateConnectionProvider(DataSource dataSource) static IDBConnectionProvider2createConnectionProvider(DataSource dataSource, String user) static DataSourcecreateDataSource(Map<Object, Object> properties) static DataSourcecreateDataSource(Map<Object, Object> properties, String namespace) static DataSourcestatic IDBSchemacreateSchema(String name) Creates a case-insensitive schema with the givenname.static IDBSchemacreateSchema(String name, boolean caseSensitive, boolean qualifiedTableNames) static voiddeserializeTable(org.eclipse.net4j.util.io.ExtendedDataInput in, Connection connection, IDBTable table, org.eclipse.net4j.util.om.monitor.OMMonitor monitor) static voiddeserializeTable(org.eclipse.net4j.util.io.ExtendedDataInput in, Connection connection, IDBTable table, org.eclipse.net4j.util.om.monitor.OMMonitor monitor, DBUtil.DeserializeRowHandler handler) dropAllTables(Connection connection, String schemaName) dropAllTables(Connection connection, String schemaName, boolean caseSensitive) static voiddump(IDBNamedElement namedElement) static voiddump(IDBNamedElement namedElement, Writer writer) static StringdumpToString(IDBNamedElement namedElement) static booleanequalNames(String name1, String name2, boolean caseSensitive) static voidexecute(Connection connection, CharSequence sql) static <T> Texecute(IDBConnectionProvider connectionProvider, DBUtil.RunnableWithConnection<T> runnable) static voidexecuteBatch(PreparedStatement stmt, int counter) static voidexecuteBatch(PreparedStatement stmt, int counter, boolean checkExactlyOne) static voidforEachTable(Connection connection, String schemaName, boolean caseSensitive, org.eclipse.net4j.util.ConsumerWithException<String, SQLException> tableNameConsumer) getAllSchemaNames(Connection connection) getAllSchemaNames(DatabaseMetaData metaData) getAllSchemaTableNames(Connection connection) Veraltet.getAllSchemaTableNames(DatabaseMetaData metaData) Veraltet.As of 4.2 usegetAllSchemaNames(DatabaseMetaData).getAllTableNames(Connection connection, String schemaName) getAllTableNames(Connection connection, String schemaName, boolean caseSensitive) static IDBAdaptergetDBAdapter(String adapterName) Retrieves anadapterfrom theadapter registry.static intgetRowCount(Connection connection, String tableName) Returns the number of rows contained in the given table.static intgetRowCount(ResultSet resultSet) Returns the number of rows contained in the given result set.static booleanisOptional(IDBElement element) static booleanstatic Stringstatic Stringstatic Stringstatic IDBDatabaseopenDatabase(IDBAdapter adapter, IDBConnectionProvider connectionProvider, String schemaName) static IDBDatabaseopenDatabase(IDBAdapter adapter, IDBConnectionProvider connectionProvider, String schemaName, boolean fixNullableIndexColumns) static IDBDatabaseopenDatabase(IDBAdapter adapter, IDBConnectionProvider connectionProvider, String schemaName, boolean fixNullableIndexColumns, boolean qualifiedTableNames) static Stringstatic IDBSchemareadSchema(IDBAdapter adapter, Connection connection, String name) static IDBSchemareadSchema(IDBAdapter adapter, Connection connection, String name, boolean fixNullableIndexColumns) static IDBSchemareadSchema(IDBAdapter adapter, Connection connection, String name, boolean fixNullableIndexColumns, boolean qualifiedTableNames) static voidreadSchema(IDBAdapter adapter, Connection connection, IDBSchema schema) static ExceptionrollbackSilently(Connection connection) static Object[]select(Connection connection, String where, IDBField... fields) static intselect(Connection connection, IDBRowHandler rowHandler, String where, IDBField... fields) static intselect(Connection connection, IDBRowHandler rowHandler, IDBField... fields) static intselectMaximumInt(Connection connection, IDBField field, String... where) static longselectMaximumLong(Connection connection, IDBField field, String... where) static intselectMinimumInt(Connection connection, IDBField field, String... where) static longselectMinimumLong(Connection connection, IDBField field, String... where) static voidserializeTable(org.eclipse.net4j.util.io.ExtendedDataOutput out, Connection connection, IDBTable table, String tableAlias, String sqlSuffix) static voidserializeTable(org.eclipse.net4j.util.io.ExtendedDataOutput out, Connection connection, IDBTable table, String tableAlias, String sqlSuffix, DBUtil.SerializeRowHandler handler) static booleansetAutoCommit(Connection connection, boolean autoCommit) static booleansetOptional(IDBElement element, boolean optional) static voidsqlDump(Connection conn, String sql) Veraltet.Should only be used when debugging.static voidsqlDump(IDBConnectionProvider connectionProvider, String sql) Veraltet.Should only be used when debugging.static Stringstatic intupdate(Connection connection, String sql) static intupdate(PreparedStatement stmt, boolean exactlyOne) Execute update on the given prepared statement and handle common cases of return values.
-
Felddetails
-
QUOTE
- Seit:
- 4.12
- Siehe auch:
-
MAX_BATCH_SIZE
public static final int MAX_BATCH_SIZE- Seit:
- 4.2
-
DISABLE_QUOTED_NAMES
public static final boolean DISABLE_QUOTED_NAMES- Seit:
- 4.12
-
PROP_ENABLE_NOISY_CLOSE
A system property to enable noisy close, i.e. exception catch in close methods are thrown asDBExceptionexception.- Seit:
- 4.4
- Siehe auch:
-
ALL_TABLE_NAME_TYPES
- Seit:
- 4.12
-
-
Methodendetails
-
dumpToString
- Seit:
- 4.2
-
dump
- Seit:
- 4.2
-
dump
- Löst aus:
IOException- Seit:
- 4.2
-
openDatabase
public static IDBDatabase openDatabase(IDBAdapter adapter, IDBConnectionProvider connectionProvider, String schemaName) - Seit:
- 4.2
-
openDatabase
public static IDBDatabase openDatabase(IDBAdapter adapter, IDBConnectionProvider connectionProvider, String schemaName, boolean fixNullableIndexColumns) - Seit:
- 4.2
-
openDatabase
public static IDBDatabase openDatabase(IDBAdapter adapter, IDBConnectionProvider connectionProvider, String schemaName, boolean fixNullableIndexColumns, boolean qualifiedTableNames) - Seit:
- 4.12
-
createSchema
Creates a case-insensitive schema with the givenname. -
createSchema
public static IDBSchema createSchema(String name, boolean caseSensitive, boolean qualifiedTableNames) - Seit:
- 4.12
-
readSchema
- Seit:
- 4.2
-
readSchema
- Seit:
- 4.2
-
readSchema
public static IDBSchema readSchema(IDBAdapter adapter, Connection connection, String name, boolean fixNullableIndexColumns) - Seit:
- 4.2
-
readSchema
public static IDBSchema readSchema(IDBAdapter adapter, Connection connection, String name, boolean fixNullableIndexColumns, boolean qualifiedTableNames) - Seit:
- 4.12
-
copySchema
- Seit:
- 4.2
-
createDataSource
-
createDataSource
-
createDataSource
-
createConnectionProvider
-
createConnectionProvider
- Seit:
- 4.3
-
getDBAdapter
Retrieves anadapterfrom theadapter registry.If Eclipse is running adapters are automatically created from descriptors that are contributed to the extension point
org.eclipse.net4j.db.dbAdapters.In standalone scenarios the needed adapter instances must be registered with the
adapter registrymanually. -
batched
public static BatchedStatement batched(PreparedStatement delegate, int batchSize) throws DBException - Löst aus:
DBException- Seit:
- 4.5
-
close
-
close
-
close
-
isOptional
- Seit:
- 4.6
-
setOptional
- Seit:
- 4.6
-
setAutoCommit
- Seit:
- 4.2
-
rollbackSilently
- Seit:
- 4.2
-
quoted
- Seit:
- 4.12
-
name
- Seit:
- 4.12
-
name
- Seit:
- 4.12
-
name
- Seit:
- 4.12
-
equalNames
- Seit:
- 4.12
-
containsName
- Seit:
- 4.12
-
getAllSchemaNames
- Seit:
- 4.2
-
getAllSchemaNames
- Seit:
- 4.2
-
getAllTableNames
-
getAllTableNames
public static List<String> getAllTableNames(Connection connection, String schemaName, boolean caseSensitive) - Seit:
- 4.12
-
forEachTable
public static void forEachTable(Connection connection, String schemaName, boolean caseSensitive, org.eclipse.net4j.util.ConsumerWithException<String, SQLException> tableNameConsumer) - Seit:
- 4.12
-
dropAllTables
- Seit:
- 4.0
-
dropAllTables
public static List<Exception> dropAllTables(Connection connection, String schemaName, boolean caseSensitive) - Seit:
- 4.12
-
asInt
- Seit:
- 4.2
-
asLong
- Seit:
- 4.2
-
selectMinimumInt
public static int selectMinimumInt(Connection connection, IDBField field, String... where) throws DBException - Löst aus:
DBException- Seit:
- 3.0
-
selectMinimumLong
public static long selectMinimumLong(Connection connection, IDBField field, String... where) throws DBException - Löst aus:
DBException- Seit:
- 3.0
-
selectMaximumInt
public static int selectMaximumInt(Connection connection, IDBField field, String... where) throws DBException - Löst aus:
DBException- Seit:
- 3.0
-
selectMaximumLong
public static long selectMaximumLong(Connection connection, IDBField field, String... where) throws DBException - Löst aus:
DBException- Seit:
- 3.0
-
execute
public static <T> T execute(IDBConnectionProvider connectionProvider, DBUtil.RunnableWithConnection<T> runnable) - Seit:
- 4.2
-
execute
- Seit:
- 4.2
-
executeBatch
- Seit:
- 4.1
-
executeBatch
- Seit:
- 4.1
-
update
-
update
Execute update on the given prepared statement and handle common cases of return values.- Parameter:
stmt- the prepared statementexactlyOne- iftrue, the update count is checked to be1. Else the update result is only checked so that the update was successful (i.e. result code != Statement.EXECUTE_FAILED).- Gibt zurück:
- the update count / execution result as returned by
PreparedStatement.executeUpdate(). Can be used by the caller to perform more advanced checks. - Löst aus:
SQLException- ifPreparedStatement.executeUpdate()throws it.IllegalStateException- if the check indicated byexcatlyOneindicates an error.- Seit:
- 4.0
-
clearTable
- Seit:
- 4.1
-
clearTable
- Seit:
- 4.1
-
select
public static int select(Connection connection, IDBRowHandler rowHandler, String where, IDBField... fields) throws DBException - Löst aus:
DBException
-
select
public static int select(Connection connection, IDBRowHandler rowHandler, IDBField... fields) throws DBException - Löst aus:
DBException
-
select
public static Object[] select(Connection connection, String where, IDBField... fields) throws DBException - Löst aus:
DBException
-
getRowCount
Returns the number of rows contained in the given result set.The
statementof the result set must have been created withTYPE_SCROLL_INSENSITIVE.- Löst aus:
DBException- Seit:
- 4.0
-
getRowCount
Returns the number of rows contained in the given table.- Löst aus:
DBException- Seit:
- 4.5
-
serializeTable
public static void serializeTable(org.eclipse.net4j.util.io.ExtendedDataOutput out, Connection connection, IDBTable table, String tableAlias, String sqlSuffix) throws DBException, IOException - Löst aus:
DBExceptionIOException- Seit:
- 3.0
-
serializeTable
public static void serializeTable(org.eclipse.net4j.util.io.ExtendedDataOutput out, Connection connection, IDBTable table, String tableAlias, String sqlSuffix, DBUtil.SerializeRowHandler handler) throws DBException, IOException - Löst aus:
DBExceptionIOException- Seit:
- 4.1
-
deserializeTable
public static void deserializeTable(org.eclipse.net4j.util.io.ExtendedDataInput in, Connection connection, IDBTable table, org.eclipse.net4j.util.om.monitor.OMMonitor monitor) throws IOException - Löst aus:
IOException- Seit:
- 4.0
-
deserializeTable
public static void deserializeTable(org.eclipse.net4j.util.io.ExtendedDataInput in, Connection connection, IDBTable table, org.eclipse.net4j.util.om.monitor.OMMonitor monitor, DBUtil.DeserializeRowHandler handler) throws IOException - Löst aus:
IOException- Seit:
- 4.1
-
trace
- Seit:
- 3.0
-
isTracerEnabled
public static boolean isTracerEnabled()- Seit:
- 4.2
-
sqlDump
Veraltet.Should only be used when debugging.For debugging purposes ONLY!- Seit:
- 3.0
-
sqlDump
Veraltet.Should only be used when debugging.For debugging purposes ONLY!- Seit:
- 3.0
-
getAllSchemaTableNames
Veraltet.As of 4.2 usegetAllSchemaNames(Connection).- Seit:
- 3.0
-
getAllSchemaTableNames
Veraltet.As of 4.2 usegetAllSchemaNames(DatabaseMetaData).- Seit:
- 3.0
-
getAllSchemaNames(Connection).