Found 317 Articles for JDBC

Java Connection setHoldability() method with example

Revathi Satya Kondra
Updated on 30-Dec-2024 19:20:39

462 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. Syntax Following is the syntax of the Java Connection setHoldability() method − void setHoldability(int holdability) throws SQLException; Parameters This method accepts an integer value named "holdability", which is described below − Representing the ResultSet ... Read More

What is CLOSE_CURSORS_AT_COMMIT in JDBC?

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

491 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

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

Java DatabaseMetaData supportsUnion() method with example.

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

101 Views

The SQL UNION clause/operator is used to combine the results of two or more SELECT statements without returning any duplicate rows.To use this UNION clause, each SELECT statement must haveThe same number of columns selectedThe same number of column expressionsThe same data type andHave them in the same orderBut they need not have to be in the same length.The basic syntax of a UNION clause is as follows −SyntaxSELECT column1 [, column2 ] FROM table1 [, table2 ] [WHERE condition] UNION SELECT column1 [, column2 ] FROM table1 [, table2 ] [WHERE condition]The supportsUnion() method of the DatabaseMetaData interface is used to ... Read More

Java DatabaseMetaData supportsGroupBy() method with example

Rishi Raj
Updated on 08-Nov-2024 22:27:02

129 Views

In this article, we will learn how to check whether a database supports the SQL GROUP BY clause using JDBC in Java. The GROUP BY clause is used to organize identical data into groups in SQL queries, typically following the WHERE clause and preceding the ORDER BY clause. With JDBC, we can determine whether the underlying database supports this clause using the supportsGroupBy() method of the DatabaseMetaData interface. Problem StatementGiven a MySQL database, write a Java program that connects to the database and checks if the database supports the SQL GROUP BY clause.Input Database connection URL, username, and ... Read More

Java DatabaseMetaData supportsResultSetType() method with example

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

178 Views

While creating a Statement object you can choose the concurrency and the type of the ResultSet object using the following variant of the createStatement() method −Statement createStatement(int resultSetType, int resultSetConcurrency)ResultSet ConcurrencyThe concurrency of the ResultSet object determines whether its contents can be updated or not.The ResultSet interface provides two values to specify the concurrency namely −CONCUR_READ_ONLY: If you set this as a value of the concurrency while creating the ResultSet object you cannot update the contents of the ResultSet you can only read/retrieve them.CONCUR_UPDATABLE: If you set this as a value of the concurrency while creating the ResultSet object you ... Read More

Java DatabaseMetaData supportsResultSetHoldability() method with example

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

94 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 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. 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.HOLD_CURSORS_OVER_COMMIT: If the holdability of the ResultSet object is set to this value. ... Read More

Java DatabaseMetaData supportsResultSetConcurrency() method with example

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

266 Views

While creating a Statement object you can choose the concurrency and the type of the ResultSet object using the following variant of the createStatement() method −Statement createStatement(int resultSetType, int resultSetConcurrency)ResultSet ConcurrencyThe concurrency of the ResultSet object determines whether its contents can be updated or not.The ResultSet interface provides two values to specify the concurrency namely −CONCUR_READ_ONLY: If you set this as a value of the concurrency while creating the ResultSet object you cannot update the contents of the ResultSet you can only read/retrieve them.CONCUR_UPDATABLE: If you set this as a value of the concurrency while creating the ResultSet object you can update ... Read More

What are the transaction isolation levels supported by JDBC API?

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

2K+ Views

JDBC provides support 5 transaction isolation levels through Connection interface.TRANSACTION_NONE: It is represented by integer value 0 does not support transactions.TRANSACTION_READ_COMMITTED: It is represented by integer value 2 supports transactions allowing Non-Repeatable Reads and, Phantom Reads.TRANSACTION_READ_UNCOMMITTED: It is represented by integer value 1 supports transactions allowing Dirty Reads, Non-Repeatable Reads and, Phantom Reads.TRANSACTION_REPEATABLE_READ: It is represented by integer value 4 supports transactions allowing only Phantom Reads.TRANSACTION_SERIALIZABLE: It is represented by integer value 8 supports transactions with out allowing Dirty Reads, Non-Repeatable Reads and, Phantom Reads.Following JDBC example displays all the transactions levels provided by the Connection interface of the JDBC ... Read More

Java DatabaseMetaData supportsTransactionIsolationLevel() method with example

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

171 Views

JDBC provides support 5 transaction isolation levels through Connection interface.TRANSACTION_NONE: It is represented by integer value 0 does not support transactions.TRANSACTION_READ_COMMITTED: It is represented by integer value 2 supports transactions allowing Non-Repeatable Reads and, Phantom Reads.TRANSACTION_READ_UNCOMMITTED: It is represented by integer value 1 supports transactions allowing Dirty Reads, Non-Repeatable Reads and, Phantom Reads.TRANSACTION_REPEATABLE_READ: It is represented by integer value 4 supports transactions allowing only Phantom Reads.TRANSACTION_SERIALIZABLE: It is represented by integer value 8 supports transactions with out allowing Dirty Reads, Non-Repeatable Reads and, Phantom Reads.The supportsTransactionIsolationLevel() method of the DatabaseMetaData interface is used to determine whether the underlying database supports ... Read More

Advertisements