package db2; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import junit.framework.AssertionFailedError; import org.apache.log4j.Logger; import org.junit.Test; public class TestDB2 { private static Logger logger = Logger.getLogger(TestDB2.class); @Test public void testDriver() { try { Class.forName("com.ibm.db2.jcc.DB2Driver"); Connection con = DriverManager.getConnection("jdbc:db2://dev67.qa.atl.jboss.com:50000/jbossqa", "pltfrmae", "pltfrmae"); //Class.forName("com.mysql.jdbc.Driver"); //Connection con = DriverManager.getConnection("jdbc:mysql://localhost/hibernate", "hibernate", "hibernate"); String s = "select * from test"; PreparedStatement pstmt = con.prepareStatement( s, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY ); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { if (rs.isAfterLast()) { logger.debug("is after last"); } logger.debug(rs.getString(1)); } } catch (SQLException e) { throw new AssertionFailedError("The driver doesn't works."); } catch (ClassNotFoundException e) { throw new AssertionFailedError("Setup incorrect. Add the drivers to your classpath"); } } }