Data access bean types

For easy data access programming, WebSphere® Application Server provides a special class library that implements many methods of the Java Database Connectivity (JDBC) API for you. The library is essentially a set of Service Data Objects (SDO).

To make things clearer, you can refer to the classes by the name of the Java archive (JAR) file that contains them:

databeans.jar - This JAR file ships with WebSphere Application Server. This file contains classes that enable you to access the database using the JDBC API.

ivjdab.jar - This JAR file ships with Visual Age for Java. This file contains all of the classes in the databeans.jar file and classes that support easy use of the data access beans from the Visual Age for Java Visual Composition Editor.

dbbeans.jar - This JAR file ships with Rational® Application Developer. This file contains a set of data access beans to more closely conform to the JDBC 2.0 RowSet standard.

The com.ibm.db package is provided to support existing applications that use data access beans.

IBM® strongly suggests that any new applications using data access beans be developed using the com.ibm.db.beans package that is provided with Rational Application Developer.

Example: Using data access beans. Data access beans are essentially a class library that makes it easier to access a database. The library contains a set of beans with methods that access the database through the Java Database Connectivity (JDBC) API. This example shows using data access beans in WebSphere Application Server Version 5 and later to create new applications that use the com.ibm.db.beans package.
package example;
import com.ibm.db.beans.*;
import java.sql.SQLException;

public class DBSelectExample {

	public static void main(String[] args) {

		DBSelect select = null;

		select = new DBSelect();
		try {

			// Set database connection information
			select.setDriverName("COM.ibm.db2.jdbc.app.DB2Driver");
			select.setUrl("jdbc:db2:SAMPLE");
			select.setUsername("userid");
			select.setPassword("password");

			// Specify the SQL statement to be executed
			select.setCommand("SELECT * FROM DEPARTMENT");

			// Execute the statement and retrieve the result set into the cache
			select.execute();

			// If result set is not empty
			if (select.onRow()) {
				do {
					// display first column of result set
					System.out.println(select.getColumnAsString(1));
					System.out.println(select.getColumnAsString(2));
				} while (select.next());
			}

			// Release the JDBC resources and close the connection 
			select.close();

		} catch (SQLException ex) {
			ex.printStackTrace();
		}
	}
}
Reference topic    

Terms and conditions for information centers | Feedback

Last updated: April 17, 2014 04:48 PM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=phil&product=was-base-iseries&topic=dacbt
File name: rdat_dacbt.html