Found 4336 Articles for Java 8

Java Connection getCatalog() method with example

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

786 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

Java Connection setAutoCommit() method with example

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

4K+ 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

Java Connection getAutoCommit() method with example

Rishi Raj
Updated on 30-Jul-2019 22:30:26

573 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.The getAutocommit() method of the Connection interface is used to get the current value of the auto-commit in this connection.To get the auto-commit value −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 ... Read More

Java Connection releaseSavepoint() method with example

Arushi
Updated on 30-Jul-2019 22:30:26

281 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

Java Connection rollBack() method with example

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

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

Java Connection setSavepoint() method with example

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

576 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 save point using the rollback() method.You can set a save point in a database using the setSavepoint(String savepointName) method of the Connection interface.//Setting the save point Savepoint savePoint = con.setSavepoint("MysavePoint");This method accepts a string value representing the name of the save point and, returns a save point object.To set a save point −Register the driver using the registerDriver() method of the DriverManager class as −//Registering ... Read More

Java Connection getHoldability() method with example

Arushi
Updated on 30-Jul-2019 22:30:26

197 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

Java Connection setHoldability() method with example

Rishi Raj
Updated on 30-Jul-2019 22:30:26

281 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 setHoldability() method of the Connection interface is used to set the holdability of the ResultSet objects in this connection (created using this connection) to a desired value.ParametersThis method accepts an integer value representing the ResultSet holdability value you want to set. The ResultSet interface provides two values to specify the holdability of a ResultSet namely −CLOSE_CURSORS_AT_COMMIT: If the holdability of the ResultSet object is set to this value. ... Read More

What is CLOSE_CURSORS_AT_COMMIT in JDBC?

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

347 Views

CLOSE_CURSORS_AT_COMMIT is the constant value of the ResultSet interface representing the holdability value. If the ResultSet holdability is set to this value whenever you commit/save a transaction using the commit() method of the Connection interface, the ResultSet objects created in the current transaction (that are already opened) will be closed.Let us create a table with name MyPlayers in MySQL database using CREATE statement as shown below −CREATE TABLE MyPlayers(    ID INT,    First_Name VARCHAR(255),    Last_Name VARCHAR(255),    Date_Of_Birth date,    Place_Of_Birth VARCHAR(255),    Country VARCHAR(255),    PRIMARY KEY (ID) );Now, we will insert 7 records in MyPlayers table ... Read More

What is ResultSet holdability in JDBC?

Arushi
Updated on 30-Jul-2019 22:30:26

1K+ 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.You can set the ResultSet holdability using the setHoldability() method of the Connection interface.con.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT);The ResultSet interface provides two values to specify the holdability of a ResultSet namely CLOSE_CURSORS_AT_COMMIT and, HOLD_CURSORS_OVER_COMMIT.Let us create a table with name MyPlayers in MySQL database using CREATE statement as shown below −CREATE TABLE MyPlayers(    ID INT,    First_Name VARCHAR(255),    Last_Name VARCHAR(255),    Date_Of_Birth date,    Place_Of_Birth VARCHAR(255),    Country VARCHAR(255),   ... Read More

Advertisements