WebSphere Application Server Network Deployment, Version 6.0.x   Operating Systems: AIX, HP-UX, Linux, Solaris, Windows
             [TIP: Focusing the table of contents and search results]

Example: Using data access 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();
		}
	}
}



Related reference
Administrative console buttons
Administrative console page features
Reference topic    

Terms of Use | Feedback

Last updated: Mar 8, 2007 8:14:28 PM CST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/rdat_newdatbeans.html

© Copyright IBM Corporation 2002, 2006. All Rights Reserved.
This information center is powered by Eclipse technology. (http://www.eclipse.org)