Found 317 Articles for JDBC

Java Connection setHoldability() method with example

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

250 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

314 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

Java DatabaseMetaData supportsUnion() method with example.

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

39 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 30-Jul-2019 22:30:26

31 Views

The SQL GROUP BY clause is used in collaboration with the SELECT statement to arrange identical data into groups. This GROUP BY clause follows the WHERE clause in a SELECT statement and precedes the ORDER BY clause.SyntaxThe basic syntax of a GROUP BY clause is shown in the following code block. The GROUP BY clause must follow the conditions in the WHERE clause and must precede the ORDER BY clause if one is used.SELECT column1, column2 FROM table_name WHERE [ conditions ] GROUP BY column1, column2 ORDER BY column1, column2The supportsGroupBy() method of the DatabaseMetaData interface is used to determine whether ... Read More

Java DatabaseMetaData supportsResultSetType() method with example

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

83 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

24 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

147 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

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

82 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