
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 317 Articles for JDBC

1K+ Views
The setClientInfo() method of the Connection interface sets values to the client info properties of the current connection object.ParametersThis method accepts a Properties object as a parameter.con.setClientInfo(properties);To set values to the client info properties file.Register the driver using the registerDriver() method of the DriverManager class as −//Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get the connection using the getConnection() method of the DriverManager class as −//Getting the connection String url = "jdbc:mysql://localhost/mydatabase"; Connection con = DriverManager.getConnection(url, "root", "password");Create a properties object as −Properties properties = new Properties();Add the required key-value pairs to the above created Properties object as −properties.put("user_name", "new_user"); properties.put("password", "password");Set the above created ... Read More

2K+ Views
One of the variant of the getConnection() method of the DriverManager class accepts url of the database, (String format) a properties file and establishes connection with the database.Connection con = DriverManager.getConnection(url, properties);To establish a connection with a database using this method −Set the Driver class name as a system property −System.setProperty("Jdbc.drivers", "com.mysql.jdbc.Driver");Create a properties object as −Properties properties = new Properties();Add the user name and password to the above created Properties object as −properties.put("user", "root"); properties.put("password", "password");Finally invoke the getConnection() method of the DriverManager class by passing the URL and, properties object as parameters.//Getting the connection String url = "jdbc:mysql://localhost/mydatabase"; Connection con = ... Read More

2K+ Views
Generally, Data about data is known as metadata. The DatabaseMetaData interface provides methods to get information about the database you have connected with like, database name, database driver version, maximum column length, etc... The getMetaData() method of the Connection interface retrieves and returns the DatabaseMetaData object. This contains information about the database you have connected to. You can get information about the database such as the name of the database, version, driver name, user name, URL, etc… by invoking the methods of the DatabaseMetaData interface using the obtained object. This method returns the DatabaseMetaData object which holds information about the underlying ... Read More

1K+ Views
In general, a catalog is a directory which holds information about data sets, file or, a database. Whereas in a database catalog holds the list of all the databases, base tables, views (virtual tables), synonyms, value ranges, indexes, users, and user groups.The getCatalog() method of the Connection interface returns the name of the current catalog/database, of the current connection object.This method returns a Sting value representing the name of the catalog. It returns null if there is no catalog.To get the catalog name −Register the driver using the registerDriver() method of the DriverManager class as −//Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get the connection ... Read More

5K+ Views
If you commit a database, it saves all the changes that have been done till that particular point. By default, some databases commits/saves the changes done automatically.You can turn off/on the auto-commit using the setAutoCommit() method of the Connection interface.ParameterThis method accepts a boolean value as a parameter. If you pass true to this method it turns on the auto-commit feature of the database and, if you pass false to this method it turns off the auto-commit feature of the database.//Turning off the auto-commit Con.setAutoCommit(false); //Turning on the auto-commit Con.setAutoCommit(true);To change the auto-commit value −Register the driver using the registerDriver() ... Read More

879 Views
In this program, we will establish a connection to a MySQL database and check the current auto-commit setting using the getAutoCommit() method from the Connection interface. We will first disable the auto-commit feature using setAutoCommit(false) and then retrieve the current auto-commit status with getAutoCommit() to verify if it has been successfully disabled. Steps to use the getAutoCommit() method Following are the steps to use the getAutoCommit() method − First, we will import the required java.sql.Connection and java.sql.DriverManager packages. We'll establish a connection to a MySQL database using the DriverManager.getConnection() method. ... Read More

464 Views
A save point is a logical rollback point within a transaction. When you set a save point, whenever an error occurs past a save point, you can undo the events you have done up to the created save point using the rollback() method.You can set a save point in a database using the setSavepoint() method of the Connection interface.And, you can remove/release a save point using the releaseSavepoint() method.This method accepts a Savepoint object as a parameter and removes the specified Savepoint.To release a save point −Register the driver using the registerDriver() method of the DriverManager class as −//Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get the ... Read More

4K+ Views
A rollback operation undoes all the changes done by the current transaction i.e. If you call a rollBack() method of the Connection interface, all the modifications are reverted until the last commit.Con.rollback()You can also rollback the changes in the database up to a particular save point by passing the required Savepoint object as a parameter to this method as −//Setting the save point con.rollback("MysavePoint");To roll back a transactionRegister the driver using the registerDriver() method of the DriverManager class as −//Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get the connection using the getConnection() method of the DriverManager class as −//Getting the connection String url = ... Read More

945 Views
When working with databases in Java, there are scenarios where you might want to perform complex transactions involving multiple steps. To maintain control and flexibility during such operations, Savepoints come into play. The setSavepoint() method in the java.sql.Connection interface allows you to create a savepoint within a transaction, providing a mechanism to roll back to a specific point if needed. What is Savepoint? A Savepoint is a marker within a database transaction. It enables partial rollbacks, meaning you can undo a subset of changes made during a transaction without affecting the entire operation. This is particularly useful in scenarios where ... Read More

324 Views
ResultSet holdability determines whether the ResultSet objects (cursors) should be closed or held open when a transaction (that contains the said cursor/ResultSet object) is committed using the commit() method of the Connection interface.The getHoldability() method of the Connection interface is used to retrieves and returns the current holdability value of the ResultSet objects in this connection.This method returns an integer value representing the current ResultSet holdability which will be either 1 or 2 where, 1 indicates the value HOLD_CURSORS_OVER_COMMIT.If the holdability of the ResultSet object is set to this value. Whenever you commit/save a transaction using the commit() method of the Connection ... Read More