Class JdbcUtils

java.lang.Object
com.landawn.abacus.jdbc.JdbcUtils

public final class JdbcUtils extends Object
Since:
0.8
Author:
Haiyang Li
See Also:
  • Method Details

    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, Connection conn, String insertSQL) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      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();
       
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, Collection<String> selectColumnNames, Connection conn, String insertSQL) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      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();
       
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, Collection<String> selectColumnNames, int offset, int count, Connection conn, String insertSQL) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      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();
       
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, Collection<String> selectColumnNames, int offset, int count, Connection conn, String insertSQL, int batchSize, long batchIntervalInMillis) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      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 -
      batchIntervalInMillis -
      Returns:
      Throws:
      SQLException
    • importData

      public static <E extends Exception> int importData(com.landawn.abacus.util.DataSet dataset, Collection<String> selectColumnNames, int offset, int count, com.landawn.abacus.util.Throwables.Predicate<? super Object[],E> filter, Connection conn, String insertSQL, int batchSize, long batchIntervalInMillis) throws SQLException, E
      Imports the data from DataSet to database.
      Type Parameters:
      E -
      Parameters:
      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 -
      batchIntervalInMillis -
      Returns:
      Throws:
      SQLException
      E
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, Connection conn, String insertSQL, Map<String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      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 -
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, int offset, int count, Connection conn, String insertSQL, Map<String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      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 -
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, int offset, int count, Connection conn, String insertSQL, int batchSize, long batchIntervalInMillis, Map<String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      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 -
      batchIntervalInMillis -
      columnTypeMap -
      Returns:
      Throws:
      SQLException
    • importData

      public static <E extends Exception> int importData(com.landawn.abacus.util.DataSet dataset, int offset, int count, com.landawn.abacus.util.Throwables.Predicate<? super Object[],E> filter, Connection conn, String insertSQL, int batchSize, long batchIntervalInMillis, Map<String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws SQLException, E
      Imports the data from DataSet to database.
      Type Parameters:
      E -
      Parameters:
      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 -
      batchIntervalInMillis -
      columnTypeMap -
      Returns:
      Throws:
      SQLException
      E
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, Connection conn, String insertSQL, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super Object[],SQLException> stmtSetter) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      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 -
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, int offset, int count, Connection conn, String insertSQL, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super Object[],SQLException> stmtSetter) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      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 -
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, int offset, int count, Connection conn, String insertSQL, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super Object[],SQLException> stmtSetter) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      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 -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • importData

      public static <E extends Exception> int importData(com.landawn.abacus.util.DataSet dataset, int offset, int count, com.landawn.abacus.util.Throwables.Predicate<? super Object[],E> filter, Connection conn, String insertSQL, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super Object[],SQLException> stmtSetter) throws SQLException, E
      Imports the data from DataSet to database.
      Type Parameters:
      E -
      Parameters:
      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 -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      E
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, PreparedStatement stmt) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      dataset -
      stmt - the column order in the sql must be consistent with the column order in the DataSet.
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, Collection<String> selectColumnNames, PreparedStatement stmt) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      dataset -
      selectColumnNames -
      stmt - the column order in the sql must be consistent with the column order in the DataSet.
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, Collection<String> selectColumnNames, int offset, int count, PreparedStatement stmt) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      dataset -
      selectColumnNames -
      offset -
      count -
      stmt - the column order in the sql must be consistent with the column order in the DataSet.
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, Collection<String> selectColumnNames, int offset, int count, PreparedStatement stmt, int batchSize, long batchIntervalInMillis) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      dataset -
      selectColumnNames -
      offset -
      count -
      stmt - the column order in the sql must be consistent with the column order in the DataSet.
      batchSize -
      batchIntervalInMillis -
      Returns:
      Throws:
      SQLException
    • importData

      public static <E extends Exception> int importData(com.landawn.abacus.util.DataSet dataset, Collection<String> selectColumnNames, int offset, int count, com.landawn.abacus.util.Throwables.Predicate<? super Object[],E> filter, PreparedStatement stmt, int batchSize, long batchIntervalInMillis) throws SQLException, E
      Imports the data from DataSet to database.
      Type Parameters:
      E -
      Parameters:
      dataset -
      selectColumnNames -
      offset -
      count -
      filter -
      stmt - the column order in the sql must be consistent with the column order in the DataSet.
      batchSize -
      batchIntervalInMillis -
      Returns:
      Throws:
      SQLException
      E
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, PreparedStatement stmt, Map<String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      dataset -
      stmt - the column order in the sql must be consistent with the column order in the DataSet.
      columnTypeMap -
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, int offset, int count, PreparedStatement stmt, Map<String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      dataset -
      offset -
      count -
      stmt - the column order in the sql must be consistent with the column order in the DataSet.
      columnTypeMap -
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, int offset, int count, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, Map<String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      dataset -
      offset -
      count -
      stmt - the column order in the sql must be consistent with the column order in the DataSet.
      batchSize -
      batchIntervalInMillis -
      columnTypeMap -
      Returns:
      Throws:
      SQLException
    • importData

      public static <E extends Exception> int importData(com.landawn.abacus.util.DataSet dataset, int offset, int count, com.landawn.abacus.util.Throwables.Predicate<? super Object[],E> filter, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, Map<String,? extends com.landawn.abacus.type.Type> columnTypeMap) throws SQLException, E
      Imports the data from DataSet to database.
      Type Parameters:
      E -
      Parameters:
      dataset -
      offset -
      count -
      filter -
      stmt - the column order in the sql must be consistent with the column order in the DataSet.
      batchSize -
      batchIntervalInMillis -
      columnTypeMap -
      Returns:
      Throws:
      SQLException
      E
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, PreparedStatement stmt, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super Object[],SQLException> stmtSetter) throws SQLException
      Parameters:
      dataset -
      stmt -
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, int offset, int count, PreparedStatement stmt, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super Object[],SQLException> stmtSetter) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      dataset -
      offset -
      count -
      stmt - the column order in the sql must be consistent with the column order in the DataSet.
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • importData

      public static int importData(com.landawn.abacus.util.DataSet dataset, int offset, int count, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super Object[],SQLException> stmtSetter) throws SQLException
      Imports the data from DataSet to database.
      Parameters:
      dataset -
      offset -
      count -
      stmt - the column order in the sql must be consistent with the column order in the DataSet.
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • importData

      public static <E extends Exception> int importData(com.landawn.abacus.util.DataSet dataset, int offset, int count, com.landawn.abacus.util.Throwables.Predicate<? super Object[],E> filter, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super Object[],SQLException> stmtSetter) throws SQLException, E
      Imports the data from DataSet to database.
      Type Parameters:
      E -
      Parameters:
      dataset -
      offset -
      count -
      filter -
      stmt - the column order in the sql must be consistent with the column order in the DataSet.
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      E
    • importData

      public static <E extends Exception> long importData(File file, Connection conn, String insertSQL, com.landawn.abacus.util.Throwables.Function<String,Object[],E> func) throws SQLException, IOException, E
      Type Parameters:
      E -
      Parameters:
      file -
      conn -
      insertSQL -
      func -
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importData

      public static <E extends Exception> long importData(File file, long offset, long count, Connection conn, String insertSQL, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.Function<String,Object[],E> func) throws SQLException, IOException, E
      Type Parameters:
      E -
      Parameters:
      file -
      offset -
      count -
      conn -
      insertSQL -
      batchSize -
      batchIntervalInMillis -
      func -
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importData

      public static <E extends Exception> long importData(File file, PreparedStatement stmt, com.landawn.abacus.util.Throwables.Function<String,Object[],E> func) throws SQLException, IOException, E
      Type Parameters:
      E -
      Parameters:
      file -
      stmt -
      func -
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importData

      public static <E extends Exception> long importData(File file, long offset, long count, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.Function<String,Object[],E> func) throws SQLException, IOException, E
      Imports the data from file to database.
      Type Parameters:
      E -
      Parameters:
      file -
      offset -
      count -
      stmt -
      batchSize -
      batchIntervalInMillis -
      func - convert line to the parameters for record insert. Returns a null array to skip the line.
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importData

      public static <E extends Exception> long importData(InputStream is, Connection conn, String insertSQL, com.landawn.abacus.util.Throwables.Function<String,Object[],E> func) throws SQLException, IOException, E
      Type Parameters:
      E -
      Parameters:
      is -
      conn -
      insertSQL -
      func -
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importData

      public static <E extends Exception> long importData(InputStream is, long offset, long count, Connection conn, String insertSQL, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.Function<String,Object[],E> func) throws SQLException, IOException, E
      Type Parameters:
      E -
      Parameters:
      is -
      offset -
      count -
      conn -
      insertSQL -
      batchSize -
      batchIntervalInMillis -
      func -
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importData

      public static <E extends Exception> long importData(InputStream is, PreparedStatement stmt, com.landawn.abacus.util.Throwables.Function<String,Object[],E> func) throws SQLException, IOException, E
      Type Parameters:
      E -
      Parameters:
      is -
      stmt -
      func -
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importData

      public static <E extends Exception> long importData(InputStream is, long offset, long count, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.Function<String,Object[],E> func) throws SQLException, IOException, E
      Imports the data from file to database.
      Type Parameters:
      E -
      Parameters:
      is -
      offset -
      count -
      stmt -
      batchSize -
      batchIntervalInMillis -
      func - convert line to the parameters for record insert. Returns a null array to skip the line.
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importData

      public static <E extends Exception> long importData(Reader reader, Connection conn, String insertSQL, com.landawn.abacus.util.Throwables.Function<String,Object[],E> func) throws SQLException, IOException, E
      Type Parameters:
      E -
      Parameters:
      reader -
      conn -
      insertSQL -
      func -
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importData

      public static <E extends Exception> long importData(Reader reader, long offset, long count, Connection conn, String insertSQL, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.Function<String,Object[],E> func) throws SQLException, IOException, E
      Type Parameters:
      E -
      Parameters:
      reader -
      offset -
      count -
      conn -
      insertSQL -
      batchSize -
      batchIntervalInMillis -
      func -
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importData

      public static <E extends Exception> long importData(Reader reader, PreparedStatement stmt, com.landawn.abacus.util.Throwables.Function<String,Object[],E> func) throws SQLException, IOException, E
      Type Parameters:
      E -
      Parameters:
      reader -
      stmt -
      func -
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importData

      public static <E extends Exception> long importData(Reader reader, long offset, long count, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.Function<String,Object[],E> func) throws SQLException, IOException, E
      Imports the data from file to database.
      Type Parameters:
      E -
      Parameters:
      reader -
      offset -
      count -
      stmt -
      batchSize -
      batchIntervalInMillis -
      func - convert line to the parameters for record insert. Returns a null array to skip the line.
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importData

      public static <T> long importData(Iterator<? extends T> iter, Connection conn, String insertSQL, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super T,SQLException> stmtSetter) throws SQLException
      Type Parameters:
      T -
      Parameters:
      iter -
      conn -
      insertSQL -
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • importData

      public static <T> long importData(Iterator<? extends T> iter, long offset, long count, Connection conn, String insertSQL, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super T,SQLException> stmtSetter) throws SQLException
      Type Parameters:
      T -
      Parameters:
      iter -
      offset -
      count -
      conn -
      insertSQL -
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • importData

      public static <T, E extends Exception> long importData(Iterator<? extends T> iter, long offset, long count, com.landawn.abacus.util.Throwables.Predicate<? super T,E> filter, Connection conn, String insertSQL, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super T,SQLException> stmtSetter) throws SQLException, E
      Type Parameters:
      T -
      E -
      Parameters:
      iter -
      offset -
      count -
      filter -
      conn -
      insertSQL -
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      E
    • importData

      public static <T> long importData(Iterator<? extends T> iter, PreparedStatement stmt, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super T,SQLException> stmtSetter) throws SQLException
      Type Parameters:
      T -
      Parameters:
      iter -
      stmt -
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • importData

      public static <T> long importData(Iterator<? extends T> iter, long offset, long count, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super T,SQLException> stmtSetter) throws SQLException
      Type Parameters:
      T -
      Parameters:
      iter -
      offset -
      count -
      stmt -
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • importData

      public static <T, E extends Exception> long importData(Iterator<? extends T> iter, long offset, long count, com.landawn.abacus.util.Throwables.Predicate<? super T,E> filter, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super T,SQLException> stmtSetter) throws SQLException, E
      Imports the data from Iterator to database.
      Type Parameters:
      T -
      E -
      Parameters:
      iter -
      offset -
      count -
      filter -
      stmt -
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      E
    • importCSV

      public static long importCSV(File file, Connection conn, String insertSQL, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super String[],SQLException> stmtSetter) throws SQLException, IOException
      Imports the data from CSV to database.
      Parameters:
      file -
      conn -
      insertSQL - the column order in the sql should be consistent with the column order in the CSV file.
      stmtSetter -
      Returns:
      Throws:
      SQLException
      IOException
    • importCSV

      public static long importCSV(File file, long offset, long count, Connection conn, String insertSQL, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super String[],SQLException> stmtSetter) throws SQLException, IOException
      Parameters:
      file -
      offset -
      count -
      conn -
      insertSQL -
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      IOException
    • importCSV

      public static <E extends Exception> long importCSV(File file, long offset, long count, com.landawn.abacus.util.Throwables.Predicate<String[],E> filter, Connection conn, String insertSQL, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super String[],SQLException> stmtSetter) throws SQLException, IOException, E
      Type Parameters:
      E -
      Parameters:
      file -
      offset -
      count -
      filter -
      conn -
      insertSQL - the column order in the sql should be consistent with the column order in the CSV file.
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importCSV

      public static long importCSV(File file, PreparedStatement stmt, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super String[],SQLException> stmtSetter) throws SQLException, IOException
      Parameters:
      file -
      stmt -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      IOException
    • importCSV

      public static long importCSV(File file, long offset, long count, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super String[],SQLException> stmtSetter) throws SQLException, IOException
      Parameters:
      file -
      offset -
      count -
      stmt -
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      IOException
    • importCSV

      public static <E extends Exception> long importCSV(File file, long offset, long count, com.landawn.abacus.util.Throwables.Predicate<String[],E> filter, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super String[],SQLException> stmtSetter) throws SQLException, IOException, E
      Imports the data from CSV to database.
      Type Parameters:
      E -
      Parameters:
      file -
      offset -
      count -
      filter -
      stmt - the column order in the sql should be consistent with the column order in the CSV file.
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importCSV

      public static long importCSV(InputStream is, PreparedStatement stmt, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super String[],SQLException> stmtSetter) throws SQLException, IOException
      Parameters:
      is -
      stmt -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      IOException
    • importCSV

      public static long importCSV(InputStream is, long offset, long count, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super String[],SQLException> stmtSetter) throws SQLException, IOException
      Parameters:
      is -
      offset -
      count -
      stmt -
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      IOException
    • importCSV

      public static <E extends Exception> long importCSV(InputStream is, long offset, long count, com.landawn.abacus.util.Throwables.Predicate<String[],E> filter, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super String[],SQLException> stmtSetter) throws SQLException, IOException, E
      Imports the data from CSV to database.
      Type Parameters:
      E -
      Parameters:
      is -
      offset -
      count -
      filter -
      stmt - the column order in the sql should be consistent with the column order in the CSV file.
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      IOException
      E
    • importCSV

      public static long importCSV(Reader reader, PreparedStatement stmt, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super String[],SQLException> stmtSetter) throws SQLException, IOException
      Parameters:
      reader -
      stmt -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      IOException
    • importCSV

      public static long importCSV(Reader reader, long offset, long count, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super String[],SQLException> stmtSetter) throws SQLException, IOException
      Parameters:
      reader -
      offset -
      count -
      stmt -
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      IOException
    • importCSV

      public static <E extends Exception> long importCSV(Reader reader, long offset, long count, com.landawn.abacus.util.Throwables.Predicate<String[],E> filter, PreparedStatement stmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super String[],SQLException> stmtSetter) throws SQLException, IOException, E
      Imports the data from CSV to database.
      Type Parameters:
      E -
      Parameters:
      reader -
      offset -
      count -
      filter -
      stmt - the column order in the sql should be consistent with the column order in the CSV file.
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
      IOException
      E
    • exportCSV

      public static long exportCSV(File out, Connection conn, String querySQL) throws SQLException, IOException
      Exports the data from database to CVS. Title will be added at the first line and columns will be quoted.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      conn -
      querySQL -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(File out, Connection conn, String querySQL, long offset, long count, boolean writeTitle, boolean quoted) throws SQLException, IOException
      Exports the data from database to CVS.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      conn -
      querySQL -
      offset -
      count -
      writeTitle -
      quoted -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(File out, Connection conn, String querySQL, Collection<String> selectColumnNames, long offset, long count, boolean writeTitle, boolean quoted) throws SQLException, IOException
      Exports the data from database to CVS.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      conn -
      querySQL -
      selectColumnNames -
      offset -
      count -
      writeTitle -
      quoted -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(File out, PreparedStatement stmt) throws SQLException, IOException
      Exports the data from database to CVS. Title will be added at the first line and columns will be quoted.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      stmt -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(File out, PreparedStatement stmt, long offset, long count, boolean writeTitle, boolean quoted) throws SQLException, IOException
      Exports the data from database to CVS.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      stmt -
      offset -
      count -
      writeTitle -
      quoted -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(File out, PreparedStatement stmt, Collection<String> selectColumnNames, long offset, long count, boolean writeTitle, boolean quoted) throws SQLException, IOException
      Exports the data from database to CVS.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      stmt -
      selectColumnNames -
      offset -
      count -
      writeTitle -
      quoted -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(File out, ResultSet rs) throws SQLException, IOException
      Exports the data from database to CVS. Title will be added at the first line and columns will be quoted.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      rs -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(File out, ResultSet rs, long offset, long count, boolean writeTitle, boolean quoted) throws SQLException, IOException
      Exports the data from database to CVS.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      rs -
      offset -
      count -
      writeTitle -
      quoted -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(File out, ResultSet rs, Collection<String> selectColumnNames, long offset, long count, boolean writeTitle, boolean quoted) throws SQLException, IOException
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      rs -
      selectColumnNames -
      offset -
      count -
      writeTitle -
      quoted -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(OutputStream out, ResultSet rs) throws SQLException, IOException
      Exports the data from database to CVS. Title will be added at the first line and columns will be quoted.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      rs -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(OutputStream out, ResultSet rs, long offset, long count, boolean writeTitle, boolean quoted) throws SQLException, IOException
      Exports the data from database to CVS.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      rs -
      offset -
      count -
      writeTitle -
      quoted -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(OutputStream out, ResultSet rs, Collection<String> selectColumnNames, long offset, long count, boolean writeTitle, boolean quoted) throws SQLException, IOException
      Exports the data from database to CVS.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      rs -
      selectColumnNames -
      offset -
      count -
      writeTitle -
      quoted -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(Writer out, ResultSet rs) throws SQLException, IOException
      Exports the data from database to CVS. Title will be added at the first line and columns will be quoted.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      rs -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(Writer out, ResultSet rs, long offset, long count, boolean writeTitle, boolean quoted) throws SQLException, IOException
      Exports the data from database to CVS.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      rs -
      offset -
      count -
      writeTitle -
      quoted -
      Returns:
      Throws:
      SQLException
      IOException
    • exportCSV

      public static long exportCSV(Writer out, ResultSet rs, Collection<String> selectColumnNames, long offset, long count, boolean writeTitle, boolean quoted) throws SQLException, IOException
      Exports the data from database to CVS.
      Each line in the output file/Writer is an array of JSON String without root bracket.
      Parameters:
      out -
      rs -
      selectColumnNames -
      offset -
      count -
      writeTitle -
      quoted -
      Returns:
      Throws:
      SQLException
      IOException
    • createParamSetter

      @Beta @SequentialOnly @Stateful public static com.landawn.abacus.util.Throwables.BiConsumer<PreparedQuery,ResultSet,SQLException> createParamSetter(Jdbc.ColumnGetter<?> columnGetterForAll)
      Parameters:
      columnGetterForAll -
      Returns:
    • copy

      public static long copy(DataSource sourceDataSource, DataSource targetDataSource, String tableName) throws SQLException
      Parameters:
      sourceDataSource -
      targetDataSource -
      tableName -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(DataSource sourceDataSource, DataSource targetDataSource, String sourceTableName, String targetTableName) throws SQLException
      Parameters:
      sourceDataSource -
      targetDataSource -
      sourceTableName -
      targetTableName -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(DataSource sourceDataSource, DataSource targetDataSource, String sourceTableName, String targetTableName, int batchSize) throws SQLException
      Parameters:
      sourceDataSource -
      targetDataSource -
      sourceTableName -
      targetTableName -
      batchSize -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(DataSource sourceDataSource, DataSource targetDataSource, String sourceTableName, String targetTableName, Collection<String> selectColumnNames) throws SQLException
      Parameters:
      sourceDataSource -
      targetDataSource -
      sourceTableName -
      targetTableName -
      selectColumnNames -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(DataSource sourceDataSource, DataSource targetDataSource, String sourceTableName, String targetTableName, Collection<String> selectColumnNames, int batchSize) throws SQLException
      Parameters:
      sourceDataSource -
      targetDataSource -
      sourceTableName -
      targetTableName -
      selectColumnNames -
      batchSize -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(DataSource sourceDataSource, String selectSql, DataSource targetDataSource, String insertSql) throws SQLException
      Parameters:
      sourceDataSource -
      selectSql -
      targetDataSource -
      insertSql -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(DataSource sourceDataSource, String selectSql, int fetchSize, DataSource targetDataSource, String insertSql, int batchSize) throws SQLException
      Parameters:
      sourceDataSource -
      selectSql -
      fetchSize - it should be bigger than batchSize. It can be x times batchSize, depends on how big one record is and how much memory is available.
      targetDataSource -
      insertSql -
      batchSize -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(DataSource sourceDataSource, String selectSql, DataSource targetDataSource, String insertSql, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super ResultSet,SQLException> stmtSetter) throws SQLException
      Parameters:
      sourceDataSource -
      selectSql -
      targetDataSource -
      insertSql -
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(DataSource sourceDataSource, String selectSql, int fetchSize, DataSource targetDataSource, String insertSql, int batchSize, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super ResultSet,SQLException> stmtSetter) throws SQLException
      Parameters:
      sourceDataSource -
      selectSql -
      fetchSize - it should be bigger than batchSize. It can be x times batchSize, depends on how big one record is and how much memory is available.
      targetDataSource -
      insertSql -
      batchSize -
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(Connection sourceConn, Connection targetConn, String tableName) throws SQLException
      Parameters:
      sourceConn -
      targetConn -
      tableName -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(Connection sourceConn, Connection targetConn, String sourceTableName, String targetTableName) throws SQLException
      Parameters:
      sourceConn -
      targetConn -
      sourceTableName -
      targetTableName -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(Connection sourceConn, Connection targetConn, String sourceTableName, String targetTableName, int batchSize) throws SQLException
      Parameters:
      sourceConn -
      targetConn -
      sourceTableName -
      targetTableName -
      batchSize -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(Connection sourceConn, Connection targetConn, String sourceTableName, String targetTableName, Collection<String> selectColumnNames) throws SQLException
      Parameters:
      sourceConn -
      targetConn -
      sourceTableName -
      targetTableName -
      selectColumnNames -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(Connection sourceConn, Connection targetConn, String sourceTableName, String targetTableName, Collection<String> selectColumnNames, int batchSize) throws SQLException
      Parameters:
      sourceConn -
      targetConn -
      sourceTableName -
      targetTableName -
      selectColumnNames -
      batchSize -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(Connection sourceConn, String selectSql, Connection targetConn, String insertSql) throws SQLException
      Parameters:
      sourceConn -
      selectSql -
      targetConn -
      insertSql -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(Connection sourceConn, String selectSql, int fetchSize, Connection targetConn, String insertSql, int batchSize) throws SQLException
      Parameters:
      sourceConn -
      selectSql -
      fetchSize - it should be bigger than batchSize. It can be x times batchSize, depends on how big one record is and how much memory is available.
      targetConn -
      insertSql -
      batchSize -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(Connection sourceConn, String selectSql, Connection targetConn, String insertSql, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super ResultSet,SQLException> stmtSetter) throws SQLException
      Parameters:
      sourceConn -
      selectSql -
      targetConn -
      insertSql -
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(Connection sourceConn, String selectSql, int fetchSize, Connection targetConn, String insertSql, int batchSize, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super ResultSet,SQLException> stmtSetter) throws SQLException
      Parameters:
      sourceConn -
      selectSql -
      fetchSize - it should be bigger than batchSize. It can be x times batchSize, depends on how big one record is and how much memory is available.
      targetConn -
      insertSql -
      batchSize -
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(Connection sourceConn, String selectSql, int fetchSize, long offset, long count, Connection targetConn, String insertSql, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super ResultSet,SQLException> stmtSetter) throws SQLException
      Parameters:
      sourceConn -
      selectSql -
      fetchSize - it should be bigger than batchSize. It can be x times batchSize, depends on how big one record is and how much memory is available.
      offset -
      count -
      targetConn -
      insertSql -
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(PreparedStatement selectStmt, PreparedStatement insertStmt, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super ResultSet,SQLException> stmtSetter) throws SQLException
      Parameters:
      selectStmt -
      insertStmt -
      stmtSetter -
      Returns:
      Throws:
      SQLException
    • copy

      public static long copy(PreparedStatement selectStmt, long offset, long count, PreparedStatement insertStmt, int batchSize, long batchIntervalInMillis, com.landawn.abacus.util.Throwables.BiConsumer<? super PreparedQuery,? super ResultSet,SQLException> stmtSetter) throws SQLException
      Parameters:
      selectStmt -
      offset -
      count -
      insertStmt -
      batchSize -
      batchIntervalInMillis -
      stmtSetter -
      Returns:
      Throws:
      SQLException