How do I find out whether the underlying database supports batch processing?
Answers
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
public class DBSupportsBatchUpdates {
public static void main(String args[])throws Exception {
//Getting the connection
String mysqlUrl = "jdbc:mysql://localhost/sampleDB";
Connection con = DriverManager.getConnection(mysqlUrl, "root", "password");
System.out.println("Connection established......");
//Creating the DatabaseMetaData object
DatabaseMetaData dbMetadata = con.getMetaData();
boolean bool = dbMetadata.supportsBatchUpdates();
if(bool) {
System.out.println("Underlying database supports batch updates");
} else {
System.out.println("Underlying database doesn’t supports batch updates");
}
}
}