- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I find out whether the underlying database supports batch processing?
Not all the databases support batch processing therefore before proceeding with batch updates in your application. You need to verify whether the database you are trying to communicate supports batch processing/batch updates or not.
You can do so using the supportsBatchUpdates() method of the DatabaseMetaData interface.
Follow the steps given below:
Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as a parameter.
Connect to the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) as parameters to it.
Create a DatabaseMetaData object using the getMetaData() method of the Connection interface.
Using the obtained object invoke the supportsBatchUpdates() method. This returns true if the database you have connected to supports batch updates and it returns false if it doesn’t.
Example
Following program verifies weather underlying database supports batch updates or not.
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"); } } }
Output
Connection established...... Underlying database supports batch updates
- Related Articles
- Difference between Batch Processing and Stream Processing
- What is batch processing in JDBC?
- How to find whether a browser supports JavaScript or not?
- How do I find out the default server character set in MySQL?
- How do I remove a MySQL database?
- Write an example JDBC program demonstrating the batch processing with statement object?
- Write an example JDBC program demonstrating the batch processing with PreparedStatement object?
- Write an example JDBC program demonstrating the batch processing with CallableStatement object?
- How do I find out the size of a canvas item in Tkinter?
- What is buffering and spooling in a batch processing operating system?
- How do I access SQLite database instance on iPhone
- How do I drop a MongoDB database from the command line?
- How to do a batch insert in MySQL?
- How do I get the id after INSERT into MySQL database in Python?
- How do I show the schema of a table in a MySQL database?
