java.sql(JDBC)

Extracting Database Metadata using DatabaseMetaData

DatabaseMetaData is a JDBC interface used to obtain information about the database, JDBC driver, tables, columns, and supported database features. It is obtained from a Connection object using the getMetaData() method. Using DatabaseMetaData, a Java program can dynamically inspect database information without directly querying system tables. This is useful for database administration, debugging, database migration […]

Extracting Database Metadata using DatabaseMetaData Read More »

Understanding ResultSetMetaData and DatabaseMetaData

ResultSetMetaData and DatabaseMetaData are JDBC interfaces used to obtain information about database results and the database itself. ResultSetMetaData provides information about the columns returned by a query, such as column names, data types, and number of columns. DatabaseMetaData provides information about the database, JDBC driver, tables, supported features, and database capabilities. Both are useful when

Understanding ResultSetMetaData and DatabaseMetaData Read More »

Practice Programs on Statement and PreparedStatement

Program 1: Display All Employee Records Using Statement This program retrieves all employee records from the database using the Statement interface. The executeQuery() method executes the SELECT query and returns the records through a ResultSet. Program 2: Insert Employee Using Statement This program inserts a new employee record using the Statement interface. The executeUpdate() method

Practice Programs on Statement and PreparedStatement Read More »

Executing stored procedures using CallableStatement

A stored procedure is a precompiled group of SQL statements stored in the database and executed when required. In JDBC, the CallableStatement interface is used to call and execute stored procedures from a Java application. The Connection.prepareCall() method creates a CallableStatement object, while setXXX() methods are used to provide input parameters. The execute() method executes

Executing stored procedures using CallableStatement Read More »

Setting Transaction Isolation Levels

Transaction isolation levels in JDBC control how one transaction can see changes made by other transactions running at the same time. They help prevent problems such as dirty reads, non-repeatable reads, and phantom reads. The isolation level is set using the setTransactionIsolation() method of the Connection interface. JDBC provides four standard isolation levels: TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED,

Setting Transaction Isolation Levels Read More »

Scroll to Top