Posts

Showing posts from November 15, 2010

Statement Prepared Statement Callable Statement

Statement, Prepared Statement, Callable Statement - Statement –  Statement is the java interfaces under java.sql package. This object is used for executing the SQL Query with the execute methods.     There the three manner to execute the queries. 1)execute() - execute method are used for execute DML queries. 2)executeBatch() - This method is used for executing many queries at a time. For using this method first add the queries in addBatch() method. 3)executeQuery() - This method is used for select the data from database. This method return ResultSet of database. 4)executeUpdate() - This method is used for update records with in the database. Prepared Statement –     Prepared Statement is used for executing the queries with parameter. Any query is compiled and stored in PreparedStatement object at first time.      PreparedStatement is used for a situation where you want to execute one query with in a loop.  ...

Steps Making JDBC connection

Steps for Making JDBC connection -     There are six steps for making the JDBC connection. 1) Load the driver -     Ex -     Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);     conn = DriverManager.getConnection(“<<DSNName>>”,<< username>>, <<password>>);    It can gives the ClassNotFoundException, SQLException exceptions so use try catch block for this code.  Try {     Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);     }catch (ClassNotFoundException e) {                 // Could not find the database driver             } catch (SQLException e) {                 // Could not connect to the database         ...

JDBC Driver Types

JDBC Driver Types -     Java has four type of JDBC driver for accessing and managing the relational databases. 1.JDBC-ODBC Bridge Driver – Type 1 2.JDBC-Native API - Type 2 3.JDBC-Net-protocol driver - Type 3 4.pure Java - Type 4  JDBC ODBC Bridge Driver (Type 1) -     JDBC ODBC Bridge Driver is fully platform dependent. This driver is used for learning phase of java. For making the JDBC ODBC connection, there is need to make DSN with the database in microsoft windows. This driver makes a bridge over the java application to DSN  and DSN point to the database. JDBC-Native API / partly Java driver (Type 2) - This driver used the Native api of other language like c/c++ for making connection with database. This driver is partly written java and C (C++) language. This is vender specific driver, we need to install software for making connection through this driver. The Oracle Call Interface (OCI) driver is an example JDBC-Net-protocol dr...

about JDBC

JDBC -     JDBC terms used for java database connectivity. Java has java.sql package which support  java database connectivity (jdbc). This api provides the facility to manage database through java code.     With in the java.sql package, Java API has seven classes .     1.Date 2.DriverManager 3.DriverPropertyInfo 4.SQLPermission 5.Time 6.Timestamp 7.Types     and have 22 interfaces 1.Array 2.Blob 3.CallableStatement 4.Clob 5.Connection 6.DatabaseMetaData 7.Driver 8.NClob 9.ParameterMetaData 10.PreparedStatement 11.Ref 12.ResultSet 13.ResultSetMetaData 14.RowId 15.Savepoint 16.SQLData 17.SQLInput 18.SQLOutput 19.SQLXML 20.Statement 21.Struct 22.Wrapper and have 17 exceptions. 1.BatchUpdateException 2.DataTruncation 3.SQLClientInfoException 4.SQLDataException 5.SQLException 6.SQLFeatureNotSupportedException 7.SQLIntegrityConstraintViolationException 8.SQLInvalidAuthorizationSpec...

Recent Post

Recent Posts Widget