public class DatabaseUtilities extends Object
| Constructor and Description |
|---|
DatabaseUtilities() |
public static Connection createConnection(String url, String user, String password, boolean isReadOnly) throws SQLException
SQLExceptionpublic static Connection createConnection(String url, String user, String password) throws SQLException
SQLExceptionpublic static void close(Connection connection)
public static SQLException close(Connection connection, SQLException exception)
public static SQLException close(Statement statement, SQLException exception)
public static SQLException close(ResultSet resultSet, SQLException exception)
public static SQLException close(IResults results, SQLException exception)
public static void close(IResults results)
public static void close(Statement statement)
public static void close(ResultSet resultSet)
public static String getStatementString(Connection connection, double beforVersion, String statement, String defaultStatement) throws SQLException
SQLExceptionpublic static double getVersionAsDouble(Connection connection) throws SQLException
SQLExceptionpublic static String getProduct(Connection connection) throws SQLException
SQLExceptionpublic static String getVersion(Connection connection) throws SQLException
SQLExceptionpublic static int getMajorVersion(Connection connection) throws SQLException
SQLExceptionpublic static int getMinorVersion(Connection connection) throws SQLException
SQLExceptionpublic static Map<String,Constraint> readConstraints(Connection connection, String selectStatement, String schemaName, String tableName) throws SQLException
SQLExceptionpublic static void dropTable(Connection connection, String schemaName, String tableName) throws SQLException
SQLExceptionpublic static void dropIndex(Connection connection, String schemaName, String indexName) throws SQLException
SQLExceptionpublic static String getOwner(Connection connection, String owner) throws SQLException
SQLExceptionpublic static <T> List<T> results(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription, String statementString, IConverter<IResult,T,SQLException> function) throws SQLException
SQLExceptionpublic static <T> List<T> results(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure, IConverter<IResult,T,SQLException> function) throws SQLException
SQLExceptionpublic static <T> List<T> results(Connection connection, String statementString, IConverter<IResult,T,SQLException> function) throws SQLException
SQLExceptionpublic static <T> List<T> results(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure, IConverter<IResult,T,SQLException> resultProcedure) throws SQLException
SQLExceptionpublic static <T> List<T> results(IFactory<IBlock<RuntimeException>,IWatcher,RuntimeException> cancelWatcherFactory, Connection connection, String statementString, IConverter<IResult,T,SQLException> resultFunction) throws SQLException
SQLExceptionpublic static <T> List<T> results(IFactory<IBlock<RuntimeException>,IWatcher,RuntimeException> cancelWatcherFactory, Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure, IConverter<IResult,T,SQLException> resultConverter) throws SQLException
SQLExceptionpublic static ResultSet resultSet(Connection connection, String string) throws SQLException
SQLExceptionpublic static <T> ResultSet resultSet(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static String stringResult(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static String stringResult(Connection connection, String statementString, Object... values) throws SQLException
SQLExceptionpublic static String stringResult(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static String stringResult(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure, IConverter<IOptional<IResult,SQLException>,String,SQLException> resultFunction) throws SQLException
SQLExceptionpublic static Long longResult(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static Long longResult(Connection connection, String statementString, Object... values) throws SQLException
SQLExceptionpublic static Long longResult(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static Long longResult(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure, IConverter<IOptional<IResult,SQLException>,Long,SQLException> resultFunction) throws SQLException
SQLExceptionpublic static boolean booleanResult(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static boolean booleanResult(Connection connection, String statementString, Object... values) throws SQLException
SQLExceptionpublic static boolean booleanResult(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static <T> T result(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure, IConverter<IOptional<IResult,SQLException>,T,SQLException> resultFunction) throws SQLException
SQLExceptionpublic static <T> T result(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription, String statementString, IConverter<IOptional<IResult,SQLException>,T,SQLException> resultFunction) throws SQLException
SQLExceptionpublic static <T> T result(Connection connection, String statementString, IConverter<IOptional<IResult,SQLException>,T,SQLException> function) throws SQLException
SQLExceptionpublic static <T> T result(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure, IConverter<IOptional<IResult,SQLException>,T,SQLException> resultFunction) throws SQLException
SQLExceptionpublic static <T> List<T> results(Connection connection, String statementString, IInterruptableFunction<IResult,T,SQLException> resultFunction) throws SQLException, CanceledException
SQLExceptionCanceledExceptionpublic static <T> List<T> results(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription, String statementString, IInterruptableFunction<IResult,T,SQLException> resultFunction) throws SQLException, CanceledException
SQLExceptionCanceledExceptionpublic static <T> List<T> results(Connection connection, String statementString, IInterruptableProcedure<PreparedStatement,SQLException> prepareClosure, IInterruptableFunction<IResult,T,SQLException> resultFunction) throws SQLException, CanceledException
SQLExceptionCanceledExceptionpublic static <T> List<T> results(IFactory<IBlock<RuntimeException>,IWatcher,RuntimeException> cancelWatcherFactory, Connection connection, String statementString, IInterruptableProcedure<PreparedStatement,SQLException> prepareClosure, IInterruptableFunction<IResult,T,SQLException> resultProcedure) throws SQLException, CanceledException
SQLExceptionCanceledExceptionpublic static <T> T aggregate(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription, String statementString, IConverter<Iterable<IResult>,T,SQLException> function) throws SQLException
SQLExceptionpublic static <T> T aggregate(Connection connection, String statementString, IConverter<Iterable<IResult>,T,SQLException> function) throws SQLException
SQLExceptionpublic static <T> T aggregate(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure, IConverter<Iterable<IResult>,T,SQLException> resultProcedure) throws SQLException
SQLExceptionpublic static boolean execute(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure, IProcedure<ResultSet,SQLException> resultProcedure) throws SQLException
SQLExceptionpublic static final boolean execute(Connection connection, String statementString, Object... values) throws SQLException
SQLExceptionpublic static final boolean call(Connection connection, String statementString, Object... values) throws SQLException
SQLExceptionpublic static final boolean call(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> procedure) throws SQLException
SQLExceptionpublic static boolean call(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure, IProcedure<ResultSet,SQLException> resultProcedure) throws SQLException
SQLExceptionpublic static IProcedure<PreparedStatement,SQLException> setterProcedur(Object... objects)
public static int count(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription, String statementString, Object... values) throws SQLException
SQLExceptionpublic static int count(Connection connection, String statementString, Object... values) throws SQLException
SQLExceptionpublic static Long next(Connection connection, String nextValueStatement) throws SQLException
SQLExceptionpublic static int count(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static int count(PreparedStatement statement, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static boolean contains(Connection connection, String statementString, String columnName, Object value) throws SQLException
SQLExceptionpublic static boolean execute(Connection connection, String statementString) throws SQLException
SQLExceptionpublic static final boolean execute(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> procedure) throws SQLException
SQLExceptionpublic static void execute(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription, IProcedure<Connection,SQLException> procedure) throws SQLException
SQLExceptionpublic static boolean exists(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription)
public static List<Object> update(Connection connection, String statementString, String[] returnColumns, Object... values) throws SQLException
SQLExceptionpublic static List<Object> update(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription, String updatetStatement, String[] returnColumns, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static List<Object> update(Connection connection, String statementString, String[] returnColumns, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static List<Object> update(Connection connection, String statementString, Object... values) throws SQLException
SQLExceptionpublic static List<Object> update(IDatabaseConnector connector, IJdbcConnectionDescription connectionDescription, String updatetStatement, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static List<Object> update(Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static <I> ICloseableConsumer<I,Boolean,SQLException> update(IFactory<IBlock<RuntimeException>,IWatcher,RuntimeException> cancelWatcherFactory, Connection connection, String statementString, IConverter<I,List<IDatabaseValue>,SQLException> converter)
public static <I> ICloseableConsumer<I,Boolean,SQLException> update(IFactory<IBlock<RuntimeException>,IWatcher,RuntimeException> cancelWatcherFactory, Connection connection, String statementString, IAggregator<PreparedStatement,I,Boolean,SQLException> aggregator)
public static void add(PreparedStatement statement, Object... values) throws SQLException
SQLExceptionpublic static void add(PreparedStatement statement, IProcedure<PreparedStatement,SQLException> prepareProcedure) throws SQLException
SQLExceptionpublic static int[] transfer(PreparedStatement statement) throws SQLException
SQLExceptionpublic IDatabaseValue value(Object object, int type)
public IDatabaseValue value(Object object, int type, String typeName)
public static <T> IClosableIterator<T,SQLException> query(IFactory<IBlock<RuntimeException>,IWatcher,RuntimeException> cancelWatcherFactory, Connection connection, String statementString, IProcedure<PreparedStatement,SQLException> prepareProcedure, IConverter<IResult,T,SQLException> converter)
public static String getSchemaName(Connection connection, String schemaName) throws SQLException
SQLExceptionpublic static void createIfNotExists(Connection connection, String schemaName, String tableName, String createStatementString) throws SQLException
SQLExceptionpublic static boolean exists(Connection connection, String schemaName, String tableName) throws SQLException
SQLExceptionpublic static boolean execute(Statement statement, String statementString) throws SQLException
SQLExceptionpublic static String createSelectStatement(String tableName, Iterable<String> columnNames, Iterable<String> valueColumnNames)
public static String createSelectStatement(String tableName, Iterable<String> columnNames, String orderByColumnName, Iterable<String> valueColumnNames)
public static String createIdentifierSelectStatement(String tableName, String identifierColumnName, Iterable<String> valueColumnNames)
public static String createIdentifierSelectStatement(String tableName, String identifierColumnName, String orderByColumnName, Iterable<String> valueColumnNames)
public static String[] getTableTypes(DatabaseMetaData metaData, IApplicable<String> applicableType) throws SQLException
SQLExceptionpublic static boolean create(Connection connection, String statementString) throws SQLException
SQLExceptionpublic static String toString(ResultSet resultSet) throws SQLException
SQLExceptionpublic static IBatchTransfer batchTransfer(Connection connection, String tableName, String[] identifierNames, String[] valueNames)
public static IBatchTransfer batchTransfer(Connection connection, String selectExistsStatement, String insertStatement, String updateStatement)
Copyright © 2007–2019 Andreas W. Bartels. All rights reserved.