public final class JdbcUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.sql.CallableStatement |
batchPrepareCall(java.sql.Connection conn,
java.lang.String sql,
java.util.List<?> parametersList) |
static java.sql.PreparedStatement |
batchPrepareStatement(java.sql.Connection conn,
java.lang.String sql,
java.util.List<?> parametersList) |
static void |
close(java.sql.Connection conn) |
static void |
close(java.sql.ResultSet rs) |
static void |
close(java.sql.ResultSet rs,
boolean closeStatement) |
static void |
close(java.sql.ResultSet rs,
boolean closeStatement,
boolean closeConnection) |
static void |
close(java.sql.ResultSet rs,
java.sql.Statement stmt) |
static void |
close(java.sql.ResultSet rs,
java.sql.Statement stmt,
java.sql.Connection conn) |
static void |
close(java.sql.Statement stmt) |
static void |
close(java.sql.Statement stmt,
java.sql.Connection conn) |
static void |
closeQuietly(java.sql.Connection conn)
Unconditionally close an
Connection . |
static void |
closeQuietly(java.sql.ResultSet rs)
Unconditionally close an
ResultSet . |
static void |
closeQuietly(java.sql.ResultSet rs,
boolean closeStatement) |
static void |
closeQuietly(java.sql.ResultSet rs,
boolean closeStatement,
boolean closeConnection) |
static void |
closeQuietly(java.sql.ResultSet rs,
java.sql.Statement stmt)
Unconditionally close the
ResultSet, Statement . |
static void |
closeQuietly(java.sql.ResultSet rs,
java.sql.Statement stmt,
java.sql.Connection conn)
Unconditionally close the
ResultSet, Statement, Connection . |
static void |
closeQuietly(java.sql.Statement stmt)
Unconditionally close an
Statement . |
static void |
closeQuietly(java.sql.Statement stmt,
java.sql.Connection conn)
Unconditionally close the
Statement, Connection . |
static long |
copy(java.sql.Connection sourceConn,
java.lang.String selectSql,
java.sql.Connection targetConn,
java.lang.String insertSql) |
static long |
copy(java.sql.Connection sourceConn,
java.lang.String selectSql,
int fetchSize,
long offset,
long count,
java.sql.Connection targetConn,
java.lang.String insertSql,
Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter,
int batchSize,
int batchInterval,
boolean inParallel) |
static long |
copy(java.sql.PreparedStatement selectStmt,
long offset,
long count,
java.sql.PreparedStatement insertStmt,
Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter,
int batchSize,
int batchInterval,
boolean inParallel) |
static long |
copy(java.sql.PreparedStatement selectStmt,
java.sql.PreparedStatement insertStmt,
Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter) |
static java.sql.Connection |
createConnection(java.lang.Class<? extends java.sql.Driver> driverClass,
java.lang.String url,
java.lang.String user,
java.lang.String password) |
static java.sql.Connection |
createConnection(java.lang.String url,
java.lang.String user,
java.lang.String password) |
static java.sql.Connection |
createConnection(java.lang.String driverClass,
java.lang.String url,
java.lang.String user,
java.lang.String password) |
static DataSource |
createDataSource(java.lang.Class<? extends java.sql.Driver> driverClass,
java.lang.String url,
java.lang.String user,
java.lang.String password) |
static DataSource |
createDataSource(java.io.InputStream dataSourceInputStream) |
static DataSource |
createDataSource(java.util.Map<java.lang.String,?> props) |
static DataSource |
createDataSource(java.lang.String dataSourceFile) |
static DataSource |
createDataSource(java.lang.String url,
java.lang.String user,
java.lang.String password) |
static DataSource |
createDataSource(java.lang.String driver,
java.lang.String url,
java.lang.String user,
java.lang.String password) |
static DataSourceManager |
createDataSourceManager(java.io.InputStream dataSourceXmlInputStream) |
static DataSourceManager |
createDataSourceManager(java.lang.String dataSourceXmlFile) |
static boolean |
createTableIfNotExists(java.sql.Connection conn,
java.lang.String tableName,
java.lang.String schema)
Returns
true if succeed to create table, otherwise false is returned. |
static boolean |
doesTableExist(java.sql.Connection conn,
java.lang.String tableName) |
static boolean |
dropTableIfExists(java.sql.Connection conn,
java.lang.String tableName)
Returns
true if succeed to drop table, otherwise false is returned. |
static boolean |
execute(java.sql.Connection conn,
java.lang.String sql,
java.lang.Object... parameters) |
static boolean |
execute(java.sql.PreparedStatement stmt) |
static int |
executeBatchUpdate(java.sql.Connection conn,
java.lang.String sql,
java.util.List<?> parametersListList) |
static int |
executeBatchUpdate(java.sql.Connection conn,
java.lang.String sql,
java.util.List<?> parametersListList,
int batchSize) |
static DataSet |
executeQuery(java.sql.Connection conn,
java.lang.String sql,
java.lang.Object... parameters) |
static DataSet |
executeQuery(java.sql.PreparedStatement stmt) |
static int |
executeUpdate(java.sql.Connection conn,
java.lang.String sql,
java.lang.Object... parameters) |
static int |
executeUpdate(java.sql.PreparedStatement stmt) |
static DataSet |
extractData(java.sql.ResultSet rs) |
static DataSet |
extractData(java.sql.ResultSet rs,
boolean closeResultSet) |
static DataSet |
extractData(java.sql.ResultSet rs,
int offset,
int count) |
static DataSet |
extractData(java.sql.ResultSet rs,
int offset,
int count,
boolean closeResultSet) |
static <E extends java.lang.Exception> |
extractData(java.sql.ResultSet rs,
int offset,
int count,
Try.Predicate<? super java.lang.Object[],E> filter,
boolean closeResultSet) |
static java.util.List<java.lang.String> |
getColumnLabelList(java.sql.ResultSet rs) |
static java.util.List<java.lang.String> |
getColumnNameList(java.sql.Connection conn,
java.lang.String tableName) |
static DBVersion |
getDBVersion(java.sql.Connection conn) |
static int |
importData(DataSet dataset,
java.util.Collection<java.lang.String> selectColumnNames,
java.sql.Connection conn,
java.lang.String insertSQL)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
java.util.Collection<java.lang.String> selectColumnNames,
int offset,
int count,
java.sql.Connection conn,
java.lang.String insertSQL)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
java.util.Collection<java.lang.String> selectColumnNames,
int offset,
int count,
java.sql.Connection conn,
java.lang.String insertSQL,
int batchSize,
int batchInterval)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
java.util.Collection<java.lang.String> selectColumnNames,
int offset,
int count,
java.sql.PreparedStatement stmt)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
java.util.Collection<java.lang.String> selectColumnNames,
int offset,
int count,
java.sql.PreparedStatement stmt,
int batchSize,
int batchInterval)
Imports the data from
DataSet to database. |
static <E extends java.lang.Exception> |
importData(DataSet dataset,
java.util.Collection<java.lang.String> selectColumnNames,
int offset,
int count,
Try.Predicate<? super java.lang.Object[],E> filter,
java.sql.Connection conn,
java.lang.String insertSQL,
int batchSize,
int batchInterval)
Imports the data from
DataSet to database. |
static <E extends java.lang.Exception> |
importData(DataSet dataset,
java.util.Collection<java.lang.String> selectColumnNames,
int offset,
int count,
Try.Predicate<? super java.lang.Object[],E> filter,
java.sql.PreparedStatement stmt,
int batchSize,
int batchInterval)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
java.util.Collection<java.lang.String> selectColumnNames,
java.sql.PreparedStatement stmt)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
java.sql.Connection conn,
java.lang.String insertSQL)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
java.sql.Connection conn,
java.lang.String insertSQL,
java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
java.sql.Connection conn,
java.lang.String insertSQL,
Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
int offset,
int count,
java.sql.Connection conn,
java.lang.String insertSQL,
int batchSize,
int batchInterval,
java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
int offset,
int count,
java.sql.Connection conn,
java.lang.String insertSQL,
int batchSize,
int batchInterval,
Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
int offset,
int count,
java.sql.Connection conn,
java.lang.String insertSQL,
java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
int offset,
int count,
java.sql.Connection conn,
java.lang.String insertSQL,
Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
int offset,
int count,
java.sql.PreparedStatement stmt,
int batchSize,
int batchInterval,
java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
int offset,
int count,
java.sql.PreparedStatement stmt,
int batchSize,
int batchInterval,
Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
int offset,
int count,
java.sql.PreparedStatement stmt,
java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
int offset,
int count,
java.sql.PreparedStatement stmt,
Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter)
Imports the data from
DataSet to database. |
static <E extends java.lang.Exception> |
importData(DataSet dataset,
int offset,
int count,
Try.Predicate<? super java.lang.Object[],E> filter,
java.sql.Connection conn,
java.lang.String insertSQL,
int batchSize,
int batchInterval,
java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap)
Imports the data from
DataSet to database. |
static <E extends java.lang.Exception> |
importData(DataSet dataset,
int offset,
int count,
Try.Predicate<? super java.lang.Object[],E> filter,
java.sql.Connection conn,
java.lang.String insertSQL,
int batchSize,
int batchInterval,
Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter)
Imports the data from
DataSet to database. |
static <E extends java.lang.Exception> |
importData(DataSet dataset,
int offset,
int count,
Try.Predicate<? super java.lang.Object[],E> filter,
java.sql.PreparedStatement stmt,
int batchSize,
int batchInterval,
java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap)
Imports the data from
DataSet to database. |
static <E extends java.lang.Exception> |
importData(DataSet dataset,
int offset,
int count,
Try.Predicate<? super java.lang.Object[],E> filter,
java.sql.PreparedStatement stmt,
int batchSize,
int batchInterval,
Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
java.sql.PreparedStatement stmt)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
java.sql.PreparedStatement stmt,
java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap)
Imports the data from
DataSet to database. |
static int |
importData(DataSet dataset,
java.sql.PreparedStatement stmt,
Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter) |
static <E extends java.lang.Exception> |
importData(java.io.File file,
java.sql.Connection conn,
java.lang.String insertSQL,
Try.Function<java.lang.String,java.lang.Object[],E> func) |
static <E extends java.lang.Exception> |
importData(java.io.File file,
long offset,
long count,
java.sql.Connection conn,
java.lang.String insertSQL,
int batchSize,
int batchInterval,
Try.Function<java.lang.String,java.lang.Object[],E> func) |
static <E extends java.lang.Exception> |
importData(java.io.File file,
long offset,
long count,
java.sql.PreparedStatement stmt,
int batchSize,
int batchInterval,
Try.Function<java.lang.String,java.lang.Object[],E> func)
Imports the data from file to database.
|
static <E extends java.lang.Exception> |
importData(java.io.File file,
java.sql.PreparedStatement stmt,
Try.Function<java.lang.String,java.lang.Object[],E> func) |
static <E extends java.lang.Exception> |
importData(java.io.InputStream is,
java.sql.Connection conn,
java.lang.String insertSQL,
Try.Function<java.lang.String,java.lang.Object[],E> func) |
static <E extends java.lang.Exception> |
importData(java.io.InputStream is,
long offset,
long count,
java.sql.Connection conn,
java.lang.String insertSQL,
int batchSize,
int batchInterval,
Try.Function<java.lang.String,java.lang.Object[],E> func) |
static <E extends java.lang.Exception> |
importData(java.io.InputStream is,
long offset,
long count,
java.sql.PreparedStatement stmt,
int batchSize,
int batchInterval,
Try.Function<java.lang.String,java.lang.Object[],E> func)
Imports the data from file to database.
|
static <E extends java.lang.Exception> |
importData(java.io.InputStream is,
java.sql.PreparedStatement stmt,
Try.Function<java.lang.String,java.lang.Object[],E> func) |
static <T> long |
importData(java.util.Iterator<T> iter,
java.sql.Connection conn,
java.lang.String insertSQL,
Try.BiConsumer<? super java.sql.PreparedStatement,? super T,java.sql.SQLException> stmtSetter) |
static <T,E extends java.lang.Exception> |
importData(java.util.Iterator<T> iter,
java.sql.Connection conn,
java.lang.String insertSQL,
Try.Function<T,java.lang.Object[],E> func) |
static <T> long |
importData(java.util.Iterator<T> iter,
long offset,
long count,
java.sql.Connection conn,
java.lang.String insertSQL,
int batchSize,
int batchInterval,
Try.BiConsumer<? super java.sql.PreparedStatement,? super T,java.sql.SQLException> stmtSetter) |
static <T,E extends java.lang.Exception> |
importData(java.util.Iterator<T> iter,
long offset,
long count,
java.sql.Connection conn,
java.lang.String insertSQL,
int batchSize,
int batchInterval,
Try.Function<T,java.lang.Object[],E> func) |
static <T> long |
importData(java.util.Iterator<T> iter,
long offset,
long count,
java.sql.PreparedStatement stmt,
int batchSize,
int batchInterval,
Try.BiConsumer<? super java.sql.PreparedStatement,? super T,java.sql.SQLException> stmtSetter) |
static <T,E extends java.lang.Exception> |
importData(java.util.Iterator<T> iter,
long offset,
long count,
java.sql.PreparedStatement stmt,
int batchSize,
int batchInterval,
Try.Function<T,java.lang.Object[],E> func)
Imports the data from Iterator to database.
|
static <T,E extends java.lang.Exception> |
importData(java.util.Iterator<T> iter,
long offset,
long count,
Try.Predicate<? super T,E> filter,
java.sql.Connection conn,
java.lang.String insertSQL,
int batchSize,
int batchInterval,
Try.BiConsumer<? super java.sql.PreparedStatement,? super T,java.sql.SQLException> stmtSetter) |
static <T,E extends java.lang.Exception> |
importData(java.util.Iterator<T> iter,
long offset,
long count,
Try.Predicate<? super T,E> filter,
java.sql.PreparedStatement stmt,
int batchSize,
int batchInterval,
Try.BiConsumer<? super java.sql.PreparedStatement,? super T,java.sql.SQLException> stmtSetter)
Imports the data from Iterator to database.
|
static <T> long |
importData(java.util.Iterator<T> iter,
java.sql.PreparedStatement stmt,
Try.BiConsumer<? super java.sql.PreparedStatement,? super T,java.sql.SQLException> stmtSetter) |
static <T,E extends java.lang.Exception> |
importData(java.util.Iterator<T> iter,
java.sql.PreparedStatement stmt,
Try.Function<T,java.lang.Object[],E> func) |
static <E extends java.lang.Exception> |
importData(java.io.Reader reader,
java.sql.Connection conn,
java.lang.String insertSQL,
Try.Function<java.lang.String,java.lang.Object[],E> func) |
static <E extends java.lang.Exception> |
importData(java.io.Reader reader,
long offset,
long count,
java.sql.Connection conn,
java.lang.String insertSQL,
int batchSize,
int batchInterval,
Try.Function<java.lang.String,java.lang.Object[],E> func) |
static <E extends java.lang.Exception> |
importData(java.io.Reader reader,
long offset,
long count,
java.sql.PreparedStatement stmt,
int batchSize,
int batchInterval,
Try.Function<java.lang.String,java.lang.Object[],E> func)
Imports the data from file to database.
|
static <E extends java.lang.Exception> |
importData(java.io.Reader reader,
java.sql.PreparedStatement stmt,
Try.Function<java.lang.String,java.lang.Object[],E> func) |
static RowIterator |
iterate(java.sql.ResultSet rs) |
static <E extends java.lang.Exception> |
parse(java.sql.Connection conn,
java.lang.String sql,
long offset,
long count,
int processThreadNum,
int queueSize,
Try.Consumer<java.lang.Object[],E> rowParser) |
static <E extends java.lang.Exception,E2 extends java.lang.Exception> |
parse(java.sql.Connection conn,
java.lang.String sql,
long offset,
long count,
int processThreadNum,
int queueSize,
Try.Consumer<java.lang.Object[],E> rowParser,
Try.Runnable<E2> onComplete)
Parse the ResultSet obtained by executing query with the specified Connection and sql.
|
static <E extends java.lang.Exception> |
parse(java.sql.Connection conn,
java.lang.String sql,
long offset,
long count,
Try.Consumer<java.lang.Object[],E> rowParser) |
static <E extends java.lang.Exception,E2 extends java.lang.Exception> |
parse(java.sql.Connection conn,
java.lang.String sql,
long offset,
long count,
Try.Consumer<java.lang.Object[],E> rowParser,
Try.Runnable<E2> onComplete) |
static <E extends java.lang.Exception> |
parse(java.sql.Connection conn,
java.lang.String sql,
Try.Consumer<java.lang.Object[],E> rowParser) |
static <E extends java.lang.Exception,E2 extends java.lang.Exception> |
parse(java.sql.Connection conn,
java.lang.String sql,
Try.Consumer<java.lang.Object[],E> rowParser,
Try.Runnable<E2> onComplete) |
static <E extends java.lang.Exception> |
parse(java.sql.PreparedStatement stmt,
long offset,
long count,
int processThreadNum,
int queueSize,
Try.Consumer<java.lang.Object[],E> rowParser) |
static <E extends java.lang.Exception,E2 extends java.lang.Exception> |
parse(java.sql.PreparedStatement stmt,
long offset,
long count,
int processThreadNum,
int queueSize,
Try.Consumer<java.lang.Object[],E> rowParser,
Try.Runnable<E2> onComplete)
Parse the ResultSet obtained by executing query with the specified PreparedStatement.
|
static <E extends java.lang.Exception> |
parse(java.sql.PreparedStatement stmt,
long offset,
long count,
Try.Consumer<java.lang.Object[],E> rowParser) |
static <E extends java.lang.Exception,E2 extends java.lang.Exception> |
parse(java.sql.PreparedStatement stmt,
long offset,
long count,
Try.Consumer<java.lang.Object[],E> rowParser,
Try.Runnable<E2> onComplete) |
static <E extends java.lang.Exception> |
parse(java.sql.PreparedStatement stmt,
Try.Consumer<java.lang.Object[],E> rowParser) |
static <E extends java.lang.Exception,E2 extends java.lang.Exception> |
parse(java.sql.PreparedStatement stmt,
Try.Consumer<java.lang.Object[],E> rowParser,
Try.Runnable<E2> onComplete) |
static <E extends java.lang.Exception> |
parse(java.sql.ResultSet rs,
long offset,
long count,
int processThreadNum,
int queueSize,
Try.Consumer<java.lang.Object[],E> rowParser) |
static <E extends java.lang.Exception,E2 extends java.lang.Exception> |
parse(java.sql.ResultSet rs,
long offset,
long count,
int processThreadNum,
int queueSize,
Try.Consumer<java.lang.Object[],E> rowParser,
Try.Runnable<E2> onComplete)
Parse the ResultSet.
|
static <E extends java.lang.Exception> |
parse(java.sql.ResultSet rs,
long offset,
long count,
Try.Consumer<java.lang.Object[],E> rowParser) |
static <E extends java.lang.Exception,E2 extends java.lang.Exception> |
parse(java.sql.ResultSet rs,
long offset,
long count,
Try.Consumer<java.lang.Object[],E> rowParser,
Try.Runnable<E2> onComplete) |
static <E extends java.lang.Exception> |
parse(java.sql.ResultSet rs,
Try.Consumer<java.lang.Object[],E> rowParser) |
static <E extends java.lang.Exception,E2 extends java.lang.Exception> |
parse(java.sql.ResultSet rs,
Try.Consumer<java.lang.Object[],E> rowParser,
Try.Runnable<E2> onComplete) |
static java.sql.CallableStatement |
prepareCall(java.sql.Connection conn,
java.lang.String sql,
java.lang.Object... parameters) |
static java.sql.PreparedStatement |
prepareStatement(java.sql.Connection conn,
java.lang.String sql,
java.lang.Object... parameters) |
static void |
skip(java.sql.ResultSet rs,
int n) |
static void |
skip(java.sql.ResultSet rs,
long n) |
static <T> Try<Stream<T>> |
stream(java.lang.Class<T> targetType,
java.sql.Connection conn,
java.lang.String sql,
java.lang.Object... parameters)
Don’t close the specified Connection before the returned
Stream is consumed/collected/terminated. |
static <T> Try<Stream<T>> |
stream(java.lang.Class<T> targetType,
java.sql.PreparedStatement stmt)
Don’t close the specified statement before the returned
Stream is consumed/collected/terminated. |
static Try<Stream<java.lang.Object[]>> |
stream(java.sql.Connection conn,
java.lang.String sql,
java.lang.Object... parameters)
Don’t close the specified Connection before the returned
Stream is consumed/collected/terminated. |
static Try<Stream<java.lang.Object[]>> |
stream(java.sql.PreparedStatement stmt)
Don’t close the specified statement before the returned
Stream is consumed/collected/terminated. |
static DataSource |
wrap(javax.sql.DataSource sqlDataSource) |
public static DBVersion getDBVersion(java.sql.Connection conn) throws UncheckedSQLException
UncheckedSQLException
public static DataSourceManager createDataSourceManager(java.lang.String dataSourceXmlFile) throws UncheckedIOException, UncheckedSQLException
dataSourceXmlFile
- UncheckedIOException
UncheckedSQLException
DataSource.xsd
public static DataSourceManager createDataSourceManager(java.io.InputStream dataSourceXmlInputStream) throws UncheckedIOException, UncheckedSQLException
dataSourceXmlInputStream
- UncheckedIOException
UncheckedSQLException
DataSource.xsd
public static DataSource createDataSource(java.lang.String dataSourceFile) throws UncheckedIOException, UncheckedSQLException
public static DataSource createDataSource(java.io.InputStream dataSourceInputStream) throws UncheckedIOException, UncheckedSQLException
public static DataSource createDataSource(java.lang.String url, java.lang.String user, java.lang.String password) throws UncheckedSQLException
UncheckedSQLException
public static DataSource createDataSource(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password) throws UncheckedSQLException
UncheckedSQLException
public static DataSource createDataSource(java.lang.Class<? extends java.sql.Driver> driverClass, java.lang.String url, java.lang.String user, java.lang.String password) throws UncheckedSQLException
UncheckedSQLException
public static DataSource createDataSource(java.util.Map<java.lang.String,?> props) throws UncheckedSQLException
props
- refer to Connection.xsd for the supported properties.UncheckedSQLException
public static DataSource wrap(javax.sql.DataSource sqlDataSource)
public static java.sql.Connection createConnection(java.lang.String url, java.lang.String user, java.lang.String password) throws UncheckedSQLException
UncheckedSQLException
public static java.sql.Connection createConnection(java.lang.String driverClass, java.lang.String url, java.lang.String user, java.lang.String password) throws UncheckedSQLException
UncheckedSQLException
public static java.sql.Connection createConnection(java.lang.Class<? extends java.sql.Driver> driverClass, java.lang.String url, java.lang.String user, java.lang.String password) throws UncheckedSQLException
UncheckedSQLException
public static void close(java.sql.ResultSet rs) throws UncheckedSQLException
UncheckedSQLException
public static void close(java.sql.ResultSet rs, boolean closeStatement) throws UncheckedSQLException
UncheckedSQLException
public static void close(java.sql.ResultSet rs, boolean closeStatement, boolean closeConnection) throws java.lang.IllegalArgumentException, UncheckedSQLException
rs
- closeStatement
- closeConnection
- java.lang.IllegalArgumentException
- if closeStatement = false
while closeConnection = true
.UncheckedSQLException
public static void close(java.sql.Statement stmt) throws UncheckedSQLException
UncheckedSQLException
public static void close(java.sql.Connection conn) throws UncheckedSQLException
UncheckedSQLException
public static void close(java.sql.ResultSet rs, java.sql.Statement stmt) throws UncheckedSQLException
UncheckedSQLException
public static void close(java.sql.Statement stmt, java.sql.Connection conn) throws UncheckedSQLException
UncheckedSQLException
public static void close(java.sql.ResultSet rs, java.sql.Statement stmt, java.sql.Connection conn) throws UncheckedSQLException
UncheckedSQLException
public static void closeQuietly(java.sql.ResultSet rs)
ResultSet
.
Equivalent to ResultSet.close()
, except any exceptions will be ignored.
This is typically used in finally blocks.
rs
- public static void closeQuietly(java.sql.ResultSet rs, boolean closeStatement) throws UncheckedSQLException
UncheckedSQLException
public static void closeQuietly(java.sql.ResultSet rs, boolean closeStatement, boolean closeConnection) throws java.lang.IllegalArgumentException
rs
- closeStatement
- closeConnection
- java.lang.IllegalArgumentException
- if closeStatement = false
while closeConnection = true
.public static void closeQuietly(java.sql.Statement stmt)
Statement
.
Equivalent to Statement.close()
, except any exceptions will be ignored.
This is typically used in finally blocks.
stmt
- public static void closeQuietly(java.sql.Connection conn)
Connection
.
Equivalent to Connection.close()
, except any exceptions will be ignored.
This is typically used in finally blocks.
conn
- public static void closeQuietly(java.sql.ResultSet rs, java.sql.Statement stmt)
ResultSet, Statement
.
Equivalent to ResultSet.close()
, Statement.close()
, except any exceptions will be ignored.
This is typically used in finally blocks.
rs
- stmt
- public static void closeQuietly(java.sql.Statement stmt, java.sql.Connection conn)
Statement, Connection
.
Equivalent to Statement.close()
, Connection.close()
, except any exceptions will be ignored.
This is typically used in finally blocks.
stmt
- conn
- public static void closeQuietly(java.sql.ResultSet rs, java.sql.Statement stmt, java.sql.Connection conn)
ResultSet, Statement, Connection
.
Equivalent to ResultSet.close()
, Statement.close()
, Connection.close()
, except any exceptions will be ignored.
This is typically used in finally blocks.
rs
- stmt
- conn
- @SafeVarargs public static java.sql.PreparedStatement prepareStatement(java.sql.Connection conn, java.lang.String sql, java.lang.Object... parameters) throws java.sql.SQLException
java.sql.SQLException
@SafeVarargs public static java.sql.CallableStatement prepareCall(java.sql.Connection conn, java.lang.String sql, java.lang.Object... parameters) throws java.sql.SQLException
java.sql.SQLException
public static java.sql.PreparedStatement batchPrepareStatement(java.sql.Connection conn, java.lang.String sql, java.util.List<?> parametersList) throws java.sql.SQLException
java.sql.SQLException
public static java.sql.CallableStatement batchPrepareCall(java.sql.Connection conn, java.lang.String sql, java.util.List<?> parametersList) throws java.sql.SQLException
java.sql.SQLException
@SafeVarargs public static DataSet executeQuery(java.sql.Connection conn, java.lang.String sql, java.lang.Object... parameters) throws UncheckedSQLException
UncheckedSQLException
public static DataSet executeQuery(java.sql.PreparedStatement stmt) throws UncheckedSQLException
UncheckedSQLException
@SafeVarargs public static int executeUpdate(java.sql.Connection conn, java.lang.String sql, java.lang.Object... parameters) throws UncheckedSQLException
UncheckedSQLException
public static int executeUpdate(java.sql.PreparedStatement stmt) throws UncheckedSQLException
UncheckedSQLException
public static int executeBatchUpdate(java.sql.Connection conn, java.lang.String sql, java.util.List<?> parametersListList) throws UncheckedSQLException
conn
- sql
- parametersListList
- UncheckedSQLException
public static int executeBatchUpdate(java.sql.Connection conn, java.lang.String sql, java.util.List<?> parametersListList, int batchSize) throws UncheckedSQLException
conn
- sql
- parametersListList
- batchSize.
- UncheckedSQLException
@SafeVarargs public static boolean execute(java.sql.Connection conn, java.lang.String sql, java.lang.Object... parameters) throws UncheckedSQLException
UncheckedSQLException
public static boolean execute(java.sql.PreparedStatement stmt) throws UncheckedSQLException
UncheckedSQLException
public static void skip(java.sql.ResultSet rs, int n) throws UncheckedSQLException
rs
- n
- the count of row to move ahead.UncheckedSQLException
public static void skip(java.sql.ResultSet rs, long n) throws UncheckedSQLException
rs
- n
- the count of row to move ahead.UncheckedSQLException
ResultSet#absolute(int)}
public static RowIterator iterate(java.sql.ResultSet rs) throws UncheckedSQLException
rs
- UncheckedSQLException
public static DataSet extractData(java.sql.ResultSet rs) throws UncheckedSQLException
rs
- UncheckedSQLException
public static DataSet extractData(java.sql.ResultSet rs, boolean closeResultSet) throws UncheckedSQLException
UncheckedSQLException
public static DataSet extractData(java.sql.ResultSet rs, int offset, int count) throws UncheckedSQLException
UncheckedSQLException
public static DataSet extractData(java.sql.ResultSet rs, int offset, int count, boolean closeResultSet) throws UncheckedSQLException
UncheckedSQLException
public static <E extends java.lang.Exception> DataSet extractData(java.sql.ResultSet rs, int offset, int count, Try.Predicate<? super java.lang.Object[],E> filter, boolean closeResultSet) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
@SafeVarargs public static Try<Stream<java.lang.Object[]>> stream(java.sql.Connection conn, java.lang.String sql, java.lang.Object... parameters) throws UncheckedSQLException
Stream
is consumed/collected/terminated.conn
- sql
- parameters
- UncheckedSQLException
@SafeVarargs public static <T> Try<Stream<T>> stream(java.lang.Class<T> targetType, java.sql.Connection conn, java.lang.String sql, java.lang.Object... parameters) throws UncheckedSQLException
Stream
is consumed/collected/terminated.targetType
- Map
or Entity
class with getter/setter methods.conn
- sql
- parameters
- UncheckedSQLException
public static Try<Stream<java.lang.Object[]>> stream(java.sql.PreparedStatement stmt) throws UncheckedSQLException
Stream
is consumed/collected/terminated.stmt
- UncheckedSQLException
public static <T> Try<Stream<T>> stream(java.lang.Class<T> targetType, java.sql.PreparedStatement stmt) throws UncheckedSQLException
Stream
is consumed/collected/terminated.targetType
- Map
or Entity
class with getter/setter methods.stmt
- UncheckedSQLException
public static int importData(DataSet dataset, java.sql.Connection conn, java.lang.String insertSQL) throws UncheckedSQLException
DataSet
to database.dataset
- conn
- insertSQL
- the column order in the sql must be consistent with the column order in the DataSet. Here is sample about how to create the sql:
List columnNameList = new ArrayList<>(dataset.columnNameList());
columnNameList.retainAll(yourSelectColumnNames);
String sql = RE.insert(columnNameList).into(tableName).sql();
UncheckedSQLException
public static int importData(DataSet dataset, java.util.Collection<java.lang.String> selectColumnNames, java.sql.Connection conn, java.lang.String insertSQL) throws UncheckedSQLException
DataSet
to database.dataset
- selectColumnNames
- conn
- insertSQL
- the column order in the sql must be consistent with the column order in the DataSet. Here is sample about how to create the sql:
List columnNameList = new ArrayList<>(dataset.columnNameList());
columnNameList.retainAll(yourSelectColumnNames);
String sql = RE.insert(columnNameList).into(tableName).sql();
UncheckedSQLException
public static int importData(DataSet dataset, java.util.Collection<java.lang.String> selectColumnNames, int offset, int count, java.sql.Connection conn, java.lang.String insertSQL) throws UncheckedSQLException
DataSet
to database.dataset
- selectColumnNames
- offset
- count
- conn
- insertSQL
- the column order in the sql must be consistent with the column order in the DataSet. Here is sample about how to create the sql:
List columnNameList = new ArrayList<>(dataset.columnNameList());
columnNameList.retainAll(yourSelectColumnNames);
String sql = RE.insert(columnNameList).into(tableName).sql();
UncheckedSQLException
public static int importData(DataSet dataset, java.util.Collection<java.lang.String> selectColumnNames, int offset, int count, java.sql.Connection conn, java.lang.String insertSQL, int batchSize, int batchInterval) throws UncheckedSQLException
DataSet
to database.dataset
- selectColumnNames
- offset
- count
- conn
- insertSQL
- the column order in the sql must be consistent with the column order in the DataSet. Here is sample about how to create the sql:
List columnNameList = new ArrayList<>(dataset.columnNameList());
columnNameList.retainAll(yourSelectColumnNames);
String sql = RE.insert(columnNameList).into(tableName).sql();
batchSize
- batchInterval
- UncheckedSQLException
public static <E extends java.lang.Exception> int importData(DataSet dataset, java.util.Collection<java.lang.String> selectColumnNames, int offset, int count, Try.Predicate<? super java.lang.Object[],E> filter, java.sql.Connection conn, java.lang.String insertSQL, int batchSize, int batchInterval) throws UncheckedSQLException, E extends java.lang.Exception
DataSet
to database.dataset
- selectColumnNames
- offset
- count
- filter
- conn
- insertSQL
- the column order in the sql must be consistent with the column order in the DataSet. Here is sample about how to create the sql:
List columnNameList = new ArrayList<>(dataset.columnNameList());
columnNameList.retainAll(yourSelectColumnNames);
String sql = RE.insert(columnNameList).into(tableName).sql();
batchSize
- batchInterval
- UncheckedSQLException
E extends java.lang.Exception
public static int importData(DataSet dataset, java.sql.Connection conn, java.lang.String insertSQL, java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws UncheckedSQLException
DataSet
to database.dataset
- conn
- insertSQL
- the column order in the sql must be consistent with the column order in the DataSet. Here is sample about how to create the sql:
List columnNameList = new ArrayList<>(dataset.columnNameList());
columnNameList.retainAll(yourSelectColumnNames);
String sql = RE.insert(columnNameList).into(tableName).sql();
columnTypeMap
- UncheckedSQLException
public static int importData(DataSet dataset, int offset, int count, java.sql.Connection conn, java.lang.String insertSQL, java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws UncheckedSQLException
DataSet
to database.dataset
- offset
- count
- conn
- insertSQL
- the column order in the sql must be consistent with the column order in the DataSet. Here is sample about how to create the sql:
List columnNameList = new ArrayList<>(dataset.columnNameList());
columnNameList.retainAll(yourSelectColumnNames);
String sql = RE.insert(columnNameList).into(tableName).sql();
columnTypeMap
- UncheckedSQLException
public static int importData(DataSet dataset, int offset, int count, java.sql.Connection conn, java.lang.String insertSQL, int batchSize, int batchInterval, java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws UncheckedSQLException
DataSet
to database.dataset
- offset
- count
- conn
- insertSQL
- the column order in the sql must be consistent with the column order in the DataSet. Here is sample about how to create the sql:
List columnNameList = new ArrayList<>(dataset.columnNameList());
columnNameList.retainAll(yourSelectColumnNames);
String sql = RE.insert(columnNameList).into(tableName).sql();
batchSize
- batchInterval
- columnTypeMap
- UncheckedSQLException
public static <E extends java.lang.Exception> int importData(DataSet dataset, int offset, int count, Try.Predicate<? super java.lang.Object[],E> filter, java.sql.Connection conn, java.lang.String insertSQL, int batchSize, int batchInterval, java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws UncheckedSQLException, E extends java.lang.Exception
DataSet
to database.dataset
- offset
- count
- filter
- conn
- insertSQL
- the column order in the sql must be consistent with the column order in the DataSet. Here is sample about how to create the sql:
List columnNameList = new ArrayList<>(dataset.columnNameList());
columnNameList.retainAll(yourSelectColumnNames);
String sql = RE.insert(columnNameList).into(tableName).sql();
batchSize
- batchInterval
- columnTypeMap
- UncheckedSQLException
E extends java.lang.Exception
public static int importData(DataSet dataset, java.sql.Connection conn, java.lang.String insertSQL, Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter) throws UncheckedSQLException
DataSet
to database.dataset
- conn
- insertSQL
- the column order in the sql must be consistent with the column order in the DataSet. Here is sample about how to create the sql:
List columnNameList = new ArrayList<>(dataset.columnNameList());
columnNameList.retainAll(yourSelectColumnNames);
String sql = RE.insert(columnNameList).into(tableName).sql();
stmtSetter
- UncheckedSQLException
public static int importData(DataSet dataset, int offset, int count, java.sql.Connection conn, java.lang.String insertSQL, Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter) throws UncheckedSQLException
DataSet
to database.dataset
- offset
- count
- conn
- insertSQL
- the column order in the sql must be consistent with the column order in the DataSet. Here is sample about how to create the sql:
List columnNameList = new ArrayList<>(dataset.columnNameList());
columnNameList.retainAll(yourSelectColumnNames);
String sql = RE.insert(columnNameList).into(tableName).sql();
stmtSetter
- UncheckedSQLException
public static int importData(DataSet dataset, int offset, int count, java.sql.Connection conn, java.lang.String insertSQL, int batchSize, int batchInterval, Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter) throws UncheckedSQLException
DataSet
to database.dataset
- offset
- count
- conn
- insertSQL
- the column order in the sql must be consistent with the column order in the DataSet. Here is sample about how to create the sql:
List columnNameList = new ArrayList<>(dataset.columnNameList());
columnNameList.retainAll(yourSelectColumnNames);
String sql = RE.insert(columnNameList).into(tableName).sql();
batchSize
- batchInterval
- stmtSetter
- UncheckedSQLException
public static <E extends java.lang.Exception> int importData(DataSet dataset, int offset, int count, Try.Predicate<? super java.lang.Object[],E> filter, java.sql.Connection conn, java.lang.String insertSQL, int batchSize, int batchInterval, Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter) throws UncheckedSQLException, E extends java.lang.Exception
DataSet
to database.dataset
- offset
- count
- filter
- conn
- insertSQL
- the column order in the sql must be consistent with the column order in the DataSet. Here is sample about how to create the sql:
List columnNameList = new ArrayList<>(dataset.columnNameList());
columnNameList.retainAll(yourSelectColumnNames);
String sql = RE.insert(columnNameList).into(tableName).sql();
batchSize
- batchInterval
- stmtSetter
- UncheckedSQLException
E extends java.lang.Exception
public static int importData(DataSet dataset, java.sql.PreparedStatement stmt) throws UncheckedSQLException
DataSet
to database.dataset
- stmt
- the column order in the sql must be consistent with the column order in the DataSet.UncheckedSQLException
public static int importData(DataSet dataset, java.util.Collection<java.lang.String> selectColumnNames, java.sql.PreparedStatement stmt) throws UncheckedSQLException
DataSet
to database.dataset
- selectColumnNames
- stmt
- the column order in the sql must be consistent with the column order in the DataSet.UncheckedSQLException
public static int importData(DataSet dataset, java.util.Collection<java.lang.String> selectColumnNames, int offset, int count, java.sql.PreparedStatement stmt) throws UncheckedSQLException
DataSet
to database.dataset
- selectColumnNames
- offset
- count
- stmt
- the column order in the sql must be consistent with the column order in the DataSet.UncheckedSQLException
public static int importData(DataSet dataset, java.util.Collection<java.lang.String> selectColumnNames, int offset, int count, java.sql.PreparedStatement stmt, int batchSize, int batchInterval) throws UncheckedSQLException
DataSet
to database.dataset
- selectColumnNames
- offset
- count
- stmt
- the column order in the sql must be consistent with the column order in the DataSet.UncheckedSQLException
public static <E extends java.lang.Exception> int importData(DataSet dataset, java.util.Collection<java.lang.String> selectColumnNames, int offset, int count, Try.Predicate<? super java.lang.Object[],E> filter, java.sql.PreparedStatement stmt, int batchSize, int batchInterval) throws UncheckedSQLException, E extends java.lang.Exception
DataSet
to database.dataset
- selectColumnNames
- offset
- count
- stmt
- the column order in the sql must be consistent with the column order in the DataSet.batchSize
- batchInterval
- UncheckedSQLException
E extends java.lang.Exception
public static int importData(DataSet dataset, java.sql.PreparedStatement stmt, java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws UncheckedSQLException
DataSet
to database.dataset
- stmt
- the column order in the sql must be consistent with the column order in the DataSet.columnTypeMap
- UncheckedSQLException
public static int importData(DataSet dataset, int offset, int count, java.sql.PreparedStatement stmt, java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws UncheckedSQLException
DataSet
to database.dataset
- offset
- count
- stmt
- the column order in the sql must be consistent with the column order in the DataSet.columnTypeMap
- UncheckedSQLException
public static int importData(DataSet dataset, int offset, int count, java.sql.PreparedStatement stmt, int batchSize, int batchInterval, java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws UncheckedSQLException
DataSet
to database.dataset
- offset
- count
- stmt
- the column order in the sql must be consistent with the column order in the DataSet.columnTypeMap
- filter
- UncheckedSQLException
public static <E extends java.lang.Exception> int importData(DataSet dataset, int offset, int count, Try.Predicate<? super java.lang.Object[],E> filter, java.sql.PreparedStatement stmt, int batchSize, int batchInterval, java.util.Map<java.lang.String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws UncheckedSQLException, E extends java.lang.Exception
DataSet
to database.dataset
- offset
- count
- filter
- stmt
- the column order in the sql must be consistent with the column order in the DataSet.batchSize
- batchInterval
- columnTypeMap
- UncheckedSQLException
E extends java.lang.Exception
public static int importData(DataSet dataset, java.sql.PreparedStatement stmt, Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter) throws UncheckedSQLException
UncheckedSQLException
public static int importData(DataSet dataset, int offset, int count, java.sql.PreparedStatement stmt, Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter) throws UncheckedSQLException
DataSet
to database.dataset
- offset
- count
- stmt
- the column order in the sql must be consistent with the column order in the DataSet.UncheckedSQLException
public static int importData(DataSet dataset, int offset, int count, java.sql.PreparedStatement stmt, int batchSize, int batchInterval, Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter) throws UncheckedSQLException
DataSet
to database.dataset
- columnTypeMap
- offset
- count
- stmt
- the column order in the sql must be consistent with the column order in the DataSet.filter
- stmtSetter
- UncheckedSQLException
public static <E extends java.lang.Exception> int importData(DataSet dataset, int offset, int count, Try.Predicate<? super java.lang.Object[],E> filter, java.sql.PreparedStatement stmt, int batchSize, int batchInterval, Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter) throws UncheckedSQLException, E extends java.lang.Exception
DataSet
to database.dataset
- offset
- count
- filter
- stmt
- the column order in the sql must be consistent with the column order in the DataSet.batchSize
- batchInterval
- stmtSetter
- columnTypeMap
- UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> long importData(java.io.File file, java.sql.Connection conn, java.lang.String insertSQL, Try.Function<java.lang.String,java.lang.Object[],E> func) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> long importData(java.io.File file, long offset, long count, java.sql.Connection conn, java.lang.String insertSQL, int batchSize, int batchInterval, Try.Function<java.lang.String,java.lang.Object[],E> func) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> long importData(java.io.File file, java.sql.PreparedStatement stmt, Try.Function<java.lang.String,java.lang.Object[],E> func) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> long importData(java.io.File file, long offset, long count, java.sql.PreparedStatement stmt, int batchSize, int batchInterval, Try.Function<java.lang.String,java.lang.Object[],E> func) throws UncheckedSQLException, E extends java.lang.Exception
file
- offset
- count
- stmt
- batchSize
- batchInterval
- func
- convert line to the parameters for record insert. Returns a null
array to skip the line.UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> long importData(java.io.InputStream is, java.sql.Connection conn, java.lang.String insertSQL, Try.Function<java.lang.String,java.lang.Object[],E> func) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> long importData(java.io.InputStream is, long offset, long count, java.sql.Connection conn, java.lang.String insertSQL, int batchSize, int batchInterval, Try.Function<java.lang.String,java.lang.Object[],E> func) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> long importData(java.io.InputStream is, java.sql.PreparedStatement stmt, Try.Function<java.lang.String,java.lang.Object[],E> func) throws E extends java.lang.Exception
E extends java.lang.Exception
public static <E extends java.lang.Exception> long importData(java.io.InputStream is, long offset, long count, java.sql.PreparedStatement stmt, int batchSize, int batchInterval, Try.Function<java.lang.String,java.lang.Object[],E> func) throws UncheckedSQLException, E extends java.lang.Exception
is
- offset
- count
- stmt
- batchSize
- batchInterval
- func
- convert line to the parameters for record insert. Returns a null
array to skip the line.UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> long importData(java.io.Reader reader, java.sql.Connection conn, java.lang.String insertSQL, Try.Function<java.lang.String,java.lang.Object[],E> func) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> long importData(java.io.Reader reader, long offset, long count, java.sql.Connection conn, java.lang.String insertSQL, int batchSize, int batchInterval, Try.Function<java.lang.String,java.lang.Object[],E> func) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> long importData(java.io.Reader reader, java.sql.PreparedStatement stmt, Try.Function<java.lang.String,java.lang.Object[],E> func) throws E extends java.lang.Exception
E extends java.lang.Exception
public static <E extends java.lang.Exception> long importData(java.io.Reader reader, long offset, long count, java.sql.PreparedStatement stmt, int batchSize, int batchInterval, Try.Function<java.lang.String,java.lang.Object[],E> func) throws UncheckedSQLException, E extends java.lang.Exception
reader
- offset
- count
- stmt
- batchSize
- batchInterval
- func
- convert line to the parameters for record insert. Returns a null
array to skip the line.UncheckedSQLException
E extends java.lang.Exception
public static <T,E extends java.lang.Exception> long importData(java.util.Iterator<T> iter, java.sql.Connection conn, java.lang.String insertSQL, Try.Function<T,java.lang.Object[],E> func) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <T,E extends java.lang.Exception> long importData(java.util.Iterator<T> iter, long offset, long count, java.sql.Connection conn, java.lang.String insertSQL, int batchSize, int batchInterval, Try.Function<T,java.lang.Object[],E> func) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <T,E extends java.lang.Exception> long importData(java.util.Iterator<T> iter, java.sql.PreparedStatement stmt, Try.Function<T,java.lang.Object[],E> func) throws E extends java.lang.Exception
E extends java.lang.Exception
public static <T,E extends java.lang.Exception> long importData(java.util.Iterator<T> iter, long offset, long count, java.sql.PreparedStatement stmt, int batchSize, int batchInterval, Try.Function<T,java.lang.Object[],E> func) throws UncheckedSQLException, E extends java.lang.Exception
iter
- offset
- count
- stmt
- batchSize
- batchInterval
- func
- convert element to the parameters for record insert. Returns a null
array to skip the line.UncheckedSQLException
E extends java.lang.Exception
public static <T> long importData(java.util.Iterator<T> iter, java.sql.Connection conn, java.lang.String insertSQL, Try.BiConsumer<? super java.sql.PreparedStatement,? super T,java.sql.SQLException> stmtSetter)
public static <T> long importData(java.util.Iterator<T> iter, long offset, long count, java.sql.Connection conn, java.lang.String insertSQL, int batchSize, int batchInterval, Try.BiConsumer<? super java.sql.PreparedStatement,? super T,java.sql.SQLException> stmtSetter)
public static <T,E extends java.lang.Exception> long importData(java.util.Iterator<T> iter, long offset, long count, Try.Predicate<? super T,E> filter, java.sql.Connection conn, java.lang.String insertSQL, int batchSize, int batchInterval, Try.BiConsumer<? super java.sql.PreparedStatement,? super T,java.sql.SQLException> stmtSetter) throws UncheckedSQLException, E extends java.lang.Exception
iter
- offset
- count
- filter
- conn
- insertSQL
- batchSize
- batchInterval
- stmtSetter
- UncheckedSQLException
E extends java.lang.Exception
public static <T> long importData(java.util.Iterator<T> iter, java.sql.PreparedStatement stmt, Try.BiConsumer<? super java.sql.PreparedStatement,? super T,java.sql.SQLException> stmtSetter)
public static <T> long importData(java.util.Iterator<T> iter, long offset, long count, java.sql.PreparedStatement stmt, int batchSize, int batchInterval, Try.BiConsumer<? super java.sql.PreparedStatement,? super T,java.sql.SQLException> stmtSetter)
public static <T,E extends java.lang.Exception> long importData(java.util.Iterator<T> iter, long offset, long count, Try.Predicate<? super T,E> filter, java.sql.PreparedStatement stmt, int batchSize, int batchInterval, Try.BiConsumer<? super java.sql.PreparedStatement,? super T,java.sql.SQLException> stmtSetter) throws UncheckedSQLException, E extends java.lang.Exception
iter
- offset
- count
- filter
- stmt
- batchSize
- batchInterval
- stmtSetter
- UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> void parse(java.sql.Connection conn, java.lang.String sql, Try.Consumer<java.lang.Object[],E> rowParser) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception,E2 extends java.lang.Exception> void parse(java.sql.Connection conn, java.lang.String sql, Try.Consumer<java.lang.Object[],E> rowParser, Try.Runnable<E2> onComplete) throws UncheckedSQLException, E extends java.lang.Exception, E2 extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> void parse(java.sql.Connection conn, java.lang.String sql, long offset, long count, Try.Consumer<java.lang.Object[],E> rowParser) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception,E2 extends java.lang.Exception> void parse(java.sql.Connection conn, java.lang.String sql, long offset, long count, Try.Consumer<java.lang.Object[],E> rowParser, Try.Runnable<E2> onComplete) throws UncheckedSQLException, E extends java.lang.Exception, E2 extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> void parse(java.sql.Connection conn, java.lang.String sql, long offset, long count, int processThreadNum, int queueSize, Try.Consumer<java.lang.Object[],E> rowParser) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception,E2 extends java.lang.Exception> void parse(java.sql.Connection conn, java.lang.String sql, long offset, long count, int processThreadNum, int queueSize, Try.Consumer<java.lang.Object[],E> rowParser, Try.Runnable<E2> onComplete) throws UncheckedSQLException, E extends java.lang.Exception, E2 extends java.lang.Exception
conn
- sql
- offset
- count
- processThreadNum
- new threads started to parse/process the lines/recordsqueueSize
- size of queue to save the processing records/lines loaded from source data. Default size is 1024.rowParser
- onComplete
- UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> void parse(java.sql.PreparedStatement stmt, Try.Consumer<java.lang.Object[],E> rowParser) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception,E2 extends java.lang.Exception> void parse(java.sql.PreparedStatement stmt, Try.Consumer<java.lang.Object[],E> rowParser, Try.Runnable<E2> onComplete) throws UncheckedSQLException, E extends java.lang.Exception, E2 extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> void parse(java.sql.PreparedStatement stmt, long offset, long count, Try.Consumer<java.lang.Object[],E> rowParser) throws E extends java.lang.Exception
E extends java.lang.Exception
public static <E extends java.lang.Exception,E2 extends java.lang.Exception> void parse(java.sql.PreparedStatement stmt, long offset, long count, Try.Consumer<java.lang.Object[],E> rowParser, Try.Runnable<E2> onComplete) throws UncheckedSQLException, E extends java.lang.Exception, E2 extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> void parse(java.sql.PreparedStatement stmt, long offset, long count, int processThreadNum, int queueSize, Try.Consumer<java.lang.Object[],E> rowParser) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception,E2 extends java.lang.Exception> void parse(java.sql.PreparedStatement stmt, long offset, long count, int processThreadNum, int queueSize, Try.Consumer<java.lang.Object[],E> rowParser, Try.Runnable<E2> onComplete) throws UncheckedSQLException, E extends java.lang.Exception, E2 extends java.lang.Exception
stmt
- offset
- count
- processThreadNum
- new threads started to parse/process the lines/recordsqueueSize
- size of queue to save the processing records/lines loaded from source data. Default size is 1024.rowParser
- onComplete
- UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> void parse(java.sql.ResultSet rs, Try.Consumer<java.lang.Object[],E> rowParser) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception,E2 extends java.lang.Exception> void parse(java.sql.ResultSet rs, Try.Consumer<java.lang.Object[],E> rowParser, Try.Runnable<E2> onComplete) throws UncheckedSQLException, E extends java.lang.Exception, E2 extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> void parse(java.sql.ResultSet rs, long offset, long count, Try.Consumer<java.lang.Object[],E> rowParser) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception,E2 extends java.lang.Exception> void parse(java.sql.ResultSet rs, long offset, long count, Try.Consumer<java.lang.Object[],E> rowParser, Try.Runnable<E2> onComplete) throws UncheckedSQLException, E extends java.lang.Exception, E2 extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception> void parse(java.sql.ResultSet rs, long offset, long count, int processThreadNum, int queueSize, Try.Consumer<java.lang.Object[],E> rowParser) throws UncheckedSQLException, E extends java.lang.Exception
UncheckedSQLException
E extends java.lang.Exception
public static <E extends java.lang.Exception,E2 extends java.lang.Exception> void parse(java.sql.ResultSet rs, long offset, long count, int processThreadNum, int queueSize, Try.Consumer<java.lang.Object[],E> rowParser, Try.Runnable<E2> onComplete) throws UncheckedSQLException, E extends java.lang.Exception, E2 extends java.lang.Exception
stmt
- offset
- count
- processThreadNum
- new threads started to parse/process the lines/recordsqueueSize
- size of queue to save the processing records/lines loaded from source data. Default size is 1024.rowParser
- onComplete
- UncheckedSQLException
E extends java.lang.Exception
public static long copy(java.sql.Connection sourceConn, java.lang.String selectSql, java.sql.Connection targetConn, java.lang.String insertSql) throws UncheckedSQLException
UncheckedSQLException
public static long copy(java.sql.Connection sourceConn, java.lang.String selectSql, int fetchSize, long offset, long count, java.sql.Connection targetConn, java.lang.String insertSql, Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter, int batchSize, int batchInterval, boolean inParallel) throws UncheckedSQLException
sourceConn
- selectSql
- fetchSize
- offset
- count
- targetConn
- insertSql
- stmtSetter
- batchSize
- batchInterval
- inParallel
- do the read and write in separated threads.UncheckedSQLException
public static long copy(java.sql.PreparedStatement selectStmt, java.sql.PreparedStatement insertStmt, Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter) throws UncheckedSQLException
UncheckedSQLException
public static long copy(java.sql.PreparedStatement selectStmt, long offset, long count, java.sql.PreparedStatement insertStmt, Try.BiConsumer<? super java.sql.PreparedStatement,? super java.lang.Object[],java.sql.SQLException> stmtSetter, int batchSize, int batchInterval, boolean inParallel) throws UncheckedSQLException
selectStmt
- offset
- count
- insertStmt
- stmtSetter
- batchSize
- batchInterval
- inParallel
- do the read and write in separated threads.UncheckedSQLException
public static boolean doesTableExist(java.sql.Connection conn, java.lang.String tableName)
public static boolean createTableIfNotExists(java.sql.Connection conn, java.lang.String tableName, java.lang.String schema)
true
if succeed to create table, otherwise false
is returned.conn
- tableName
- schema
- public static boolean dropTableIfExists(java.sql.Connection conn, java.lang.String tableName)
true
if succeed to drop table, otherwise false
is returned.conn
- tableName
- public static java.util.List<java.lang.String> getColumnNameList(java.sql.Connection conn, java.lang.String tableName) throws UncheckedSQLException
conn
- tableName
- UncheckedSQLException
public static java.util.List<java.lang.String> getColumnLabelList(java.sql.ResultSet rs) throws UncheckedSQLException
rs
- UncheckedSQLException