Java Database Connectivity
Java Database Connectivity (JDBC) is Java's API for interacting with the relational databases. JDBC is a specification interface, while individual database vendors develop the drivers library adhering to JDBC.
The following is the syntax for a simple database connection and query execution to obtain the results into the object called ResultSet
:
Connection dbConn = DriverManager.getConnection(databaseURL, username, password); Statement qryStmt = dbConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet queryResults = qryStmt.executeQuery("SELECT <COLUMNS TO RETRIEVE> FROM <TABLES / VIEWS ALONG WITH CRITERIA>");
Here is the sample program for an UpdatableResultSet
to retrieve, update, delete, and add a new row into an Oracle database:
package resultset; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class UpdatableResultSet...