Posted on August 12, 2008 by sharat
JDBC Resources A JDBC resource (data source) provides applications with a means of connecting to a database. Typically, the administrator creates a JDBC resource for each database accessed by the applications deployed in a domain. (However, more than one JDBC resource can be created for a database.) JDBC Resources To store, organize, and retrieve [...]
Filed under: JDBC | 6 Comments »
Posted on September 9, 2006 by sharat
You will get a scrollable ResultSet object if you specify one of these ResultSet constants.The difference between the two has to do with whether a result set reflects changes that are made to it while it is open and whether certain methods can be called to detect these changes. Generally speaking, a result set that [...]
Filed under: JDBC | 2 Comments »
Posted on September 9, 2006 by sharat
Another new feature in the JDBC 2.0 API is the ability to update rows in a result set using methods in the Java programming language rather than having to send an SQL command. But before you can take advantage of this capability, you need to create a ResultSet object that is updatable. In order to [...]
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an application, as exceptions do; they simply alert the user that something did not happen as planned. A warning can be reported on a Connection object, a Statement object (including PreparedStatement and CallableStatement objects), or [...]
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
Driver can be loaded in 2 ways : 1. class.forName(“sun.jdbc.odbc.JdbcOdbc”); 2. Driver d=new Driver(“sun.jdbc.odbc.JdbcOdbc”); DriverManager.registerDriver(d); vendar specific one: Driver d=new oracle.driver.oracleDriver();
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
Example: Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(SELECT COF_NAME, PRICE FROM COFFEES”); while (rs .next() ) { //Iam assuming there are 3 columns in the table. System.out.println ( rs.getString(1)); System.out.println(rs.getString(2)); System.out.println(rs.getString(3)); } //don’t forget to close the resultset, statement & connection rs.close(); //First stmt.close(); //Second con.close(); //Last System.out.println(“You are done”);
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
Connection Pooling can be implemented by the following way. A javax.sql.ConnectionPoolDataSource interface that serves as a resource manager connection factory for pooled java.sql.Connection objects. Each database vendors provide the implementation for that interface. For example, the oracle vendors implementation is as follows: oracle.jdbc.pool.oracleConnectionPoolDataSource Class. A javax.sql.PooledConnection interface encapsulates the physical connection for the database. Again, the [...]
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
Stored Procedures can be called in java by using the prepareCall() method which returns a CallableStatement object. CallableStatement cs = con.prepareCall(“{call Procedure_name}”); ResultSet rs = cs.executeQuery();
Filed under: JDBC | 1 Comment »
Posted on September 9, 2006 by sharat
1.Statement which is used to run simple sql statements like select and update 2. PrepareStatment is used to run Pre compiled sql. 3. CallableStatement is used to execute the stored procedures.
Filed under: JDBC | 1 Comment »
Posted on September 9, 2006 by sharat
A ResultSet maintains a connection to a database and because of that it can’t be serialized and also we cant pass the Resultset object from one class to other class across the network. RowSet is a disconnected, serializable version of a JDBC ResultSet and also the RowSet extends the ResultSet interface so it has all [...]
Filed under: JDBC | 7 Comments »
Posted on September 9, 2006 by sharat
To emulate a business transaction, a program may need to perform several steps. A financial program, for example, might transfer funds from a checking account to a savings account with the steps listed in the following pseudocode: begin transaction debit checking account credit savings account update history log commit transaction Either all three of these [...]
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
Autocommit behavior The JDBC specification requires that, by default, a COMMIT is performed after each data modification statement. Currently, the server-side JDBC behavior is to commit. You can control this behavior using a statement such as the following: conn.setAutoCommit( false ) ; where conn is the current connection object. Connection defaults From server-side JDBC, only the first [...]
Filed under: JDBC | 1 Comment »
Posted on September 9, 2006 by sharat
Prepared Statement is Pre-compiled class , but Statement is not. So in PreparedStatement the execution will be faster. Actually when u submit a simple statement to the databse, at first the DBMS parses it and sends it back with the result, so again when u send the same statement again the DBMS server parses it [...]
Filed under: JDBC | 12 Comments »
Posted on September 9, 2006 by sharat
Save point is a feature using which we can save status of the transaction to a perticular extent.so that if anytime we have lost a transaction we can get it back using save point.
Filed under: JDBC | 1 Comment »
Posted on September 9, 2006 by sharat
ResultSetMetaData You can interrogate JDBC for detailed information about a query’s result set using a ResultSetMetaData object. ResultSetMetaData is a class that is used to find information about the ResultSet returned from a executeQuery call. It contains information about the number of columns, the types of data they contain, the names of the columns, and [...]
Filed under: JDBC | 6 Comments »
Posted on September 9, 2006 by sharat
The JDBC drivers that support JDBC 2.0 and above support batch updates. With batch updates, instead of updating rows of a table one at a time, you can direct JDBC to execute a group of updates at the same time. Statements that can be included in the same batch of updates are known as batchable [...]
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
A transaction is atomic unit of Work.The tasks which are made into the transaction act as a unit which can be executed successfully all,or if at least one task fails to its promise ,then the effect of all the tasks are to be rollbacked.Thus transaction is committed or rolled backed. Transactions can be divided into [...]
Filed under: JDBC | 2 Comments »
Posted on September 8, 2006 by sharat
The following are the JDBC 2.0 features. Resultset enhancements JDBC 2.0 supports scrollable resultset capability under three major headings, namely, forward-only, scroll-insensitive, and scroll-sensitive. Each of these resultsets can in turn be Read_only or Updatable. Forward_only/Read_only is feature of JDBC 1.0. Batch Updates automatic batch update and explicit batch update. Advanced Data Types The advanced [...]
Filed under: JDBC | 7 Comments »
Posted on September 8, 2006 by sharat
JDBC drivers are divided into four types or levels. Each type defines a JDBC driver implementation with increasingly higher levels of platform independence, performance, and deployment administration. The four types are: Type 1: JDBC-ODBC Bridge Type 2: Native-API/partly Java driver Type 3: Net-protocol/all-Java driver Type 4: Native-protocol/all-Java driver Type 1: JDBC-ODBC Bridge The type 1 [...]
Filed under: JDBC | 5 Comments »
Posted on September 8, 2006 by sharat
JDBC (Java Database Connectivity) provides a standard interface for accessing a relational database from a Java application regardless of where the application is running and where the database is. It provides a way for Java applications to call SQL and PL/SQL. In other words it is a way to execute SQL statements and also call [...]
Filed under: JDBC | Leave a Comment »
Posted on September 8, 2006 by sharat
Basically a Java program implementing JDBC performs the following functions: Load a JDBC driver. Establish a database connection. Optionally interrogate the database for capability subset. Optionally retrieve schema metadata information. Construct a SQL or callable statement object and send queries or database tasks. Execute the database tasks or process resultsets. Close the statement object and [...]
Filed under: JDBC | 1 Comment »