数据访问 Bean 类型

为了便于进行数据访问编程,WebSphere® Application Server 提供了一个特殊的类库,它将为您实现许多 Java™ 数据库连接 (JDBC) API 方法。该库实际上是一组服务数据对象 (SDO)。

要使这些事情更清楚,您可通过包含它们的 Java 归档 (JAR) 文件的名称来引用它们:

databeans.jar - 此 JAR 文件与 WebSphere Application Server 一起提供。此文件包含允许您访问使用 JDBC API 的数据库的类。

ivjdab.jar - 此 JAR 文件与 Visual Age for Java 一起提供。 此文件包含 databeans.jar 文件中的所有类,以及支持从 Visual Age for Java Visual Composition Editor 方便地使用数据访问 Bean 的类。

dbbeans.jar - 此 JAR 文件与 Rational® Application Developer 一起提供。此文件包含一组数据访问 Bean,它们更符合 JDBC 2.0 RowSet 标准。

com.ibm.db 包是为支持使用数据访问 Bean 的现有应用程序而提供的。

IBM® 强烈建议使用 com.ibm.db.beans 包来开发使用数据访问 Bean 的任何新应用程序,此包与开发者工具一起提供。

示例:使用数据访问 Bean 数据访问 Bean 实际上是一个使得访问数据库更容易的类库。该库包含一组带有方法的 Bean,这些方法通过 Java 数据库连接 (JDBC) API 来访问数据库。此示例显示使用数据访问 Bean 来创建使用 com.ibm.db.beans 包的新应用程序。

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();
		}
	}
}

指示主题类型的图标 参考主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=rdat_dacbt
文件名:rdat_dacbt.html