JDBC Stands for Java Database Connectivity. JDBC AI used to connect java application with Database. JDBC API is the industry standard for database-independent connectivity between the Java programming language and a wide range of databases & SQL databases and other tabular data sources, such as spreadsheets or flat files.
The significances are given below: The major features introduced in JDBC 4.0 are Java applications access the database using JDBC by: The JDBC Architecture consists of two layers: The life cycle for a servlet comprises of the following phases A JDBC application may be divided into two layers: By providing the JAR file, the driver must be properly configured. Statement stmt = conn.createStatement(); Code: PreparedStatement pstmt = conn.prepareStatement(“UPDATE data= ? WHERE vl = ?”); pstmt.setBigDecimal(1, 1200.00); pstmt.setInt(2, 192); con.setAutoCommit (false); Code: con.setAutoCommit(false); PreparedStatement updateSales = con.prepareStatement( “UPDATE COFFEE SALES = ? WHERE COF_NAME LIKE ?”); updateSales.setInt(1, 50); updateSales.setString(2, “Colombian”); updateSales.executeUpdate(); PreparedStatement updateTotal = con.prepareStatement(“UPDATE COFFEES SET TOTAL = TOTAL + ? WHERE COF_NAME LIKE ?”); updateTotal.setInt(1, 50); updateTotal.setString(2, “Colombian”); updateTotal.executeUpdate(); con.commit(); con.setAutoCommit(true); Code: CallableStatement cs = con.prepareCall(“{call SHOW_Sales}”); ResultSet rs = cs.executeQuery(); Code : SQLWarning waring = stmt.getWarnings(); if (warning != null) { System.out.println(“n—Warning—n”); while (warning != null) { System.out.println(“Message: ” + warning.getMessage()); System.out.println(“SQLState: ” + warning.getSQLState()); System.out.println(“Vendor error code: “); System.out.println(warning.getErrorCode()); System.out.println(“”); warning = warning.getNextWarning(); } } The 4 types of JDBC Drivers are: Code: Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet srs = stmt.executeQuery(”SELECT COF_NAME, Sale _COFFEE”); Three constants can be added to the Result Set API for indicating the kind of the Result Set object. The constants are: – TYPE_FORWARD_ONLY – TYPE_SCROLL_INSENSITIVE – TYPE_SCROLL_SENSITIVE. The Result Set constants for specifying whether a result set is read-only or updatable are: – CONCUR_READ_ONLY – CONCUR_UPDATABLE. Class.forName(”sun.jdbc.odbc.JdbcOdbcDriver”); For example, if the class name is jdbc.DriverXYZ, we can load the driver using the below line of code: Code: Class.forName(”jdbc.DriverXYZ”); Code: String url = “jdbc:odbc: rima”; Connection con = DriverManager.getConnection(url, “rima”, “J8?);Discuss the significances of JDBC?
Name the new features added in JDBC 4.0?
How do Java applications access the database using JDBC?
Briefly tell about the JDBC Architecture?
Explain the life cycle of JDBC?
Describe how the JDBC application works?
How a database driver can be loaded with JDBC 4.0 / Java 6?
What does the JDBC Driver interface do?
What is represented by the connection object?
What is a Statement?
Define PreparedStatement
Differentiate between a Statement and a PreparedStatement
What is the function of setAutoCommit?
How do we call a stored procedure from JDBC?
What is SQLWarning and discuss the procedure of retrieving warnings?
Explain the types of JDBC Drivers and name them
How can we move the cursor in a scrollable result set?
How do we load the drivers?
What Class.forName does, while loading the drivers?
How can you make a connection?
Related posts:
- Database Interview Questions and Answers
- DB2 Interview Questions and Answers
- DBMS Interview Questions and Answers
- MySQL Interview Questions & Answers
- Neo4j Interview Questions and Answers
- SQL Interview Questions and Answers
- SQL Server 2008 Interview Questions and Answers
- SQLite Interview Questions and Answers