Check If database support batch update in Java

Description

The following code shows how to check If database support batch update.

Example


import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
/*from   w w  w .j  a  v a2s  .  c  om*/
public class Main {
  public static void main(String[] args) throws Exception {
    Connection connection = getConnection();
    DatabaseMetaData metadata = connection.getMetaData();

    boolean isBatchingSupported = metadata.supportsBatchUpdates();
    System.out.println("Batching Supported = " + isBatchingSupported);
    connection.close();
  }

  private static Connection getConnection() throws Exception {
    Class.forName("org.hsqldb.jdbcDriver");
    String url = "jdbc:hsqldb:mem:data/tutorial";

    return DriverManager.getConnection(url, "sa", "");
  }
}




















Home »
  Java Tutorial »
    JDBC »




Batch
Binary Data
Database
Date Time
Insert
ResultSet
SQL
Statement
Stored Function
Table