Hi, I'm having problem in retriving records from the DB2 database. The follwing is my code:
String sql = "select * from user";
execQuery(sql);
public void execQuery(String sql) throws SQLException, NullPointerException, Exception
{
if (sql == "" || sql == null) {
throw new Exception("sql cannot be null");
}
PoolManager poolMgr = null;
Connection conn = null;
Statement stmt = null;
ResultSet rst = null;
ResultSetMetaData rsmd = null;
Vector v = new Vector();
try {
poolMgr = PoolManager.getInstance();
System.out.println("poolMgr instantiated");
conn = poolMgr.getConnection();
System.out.println("conn instantiated");
stmt = conn.createStatement();
System.out.println("stmt instantiated");
rst = stmt.executeQuery(sql);
}
catch (SQLException sqle) {
System.out.println("sqle :" + sqle.getMessage());
catch (NullPointerException npe) {
System.out.println("npe :" + npe.getMessage());
}
catch (Exception e) {
System.out.println("e :" + e.getMessage());
}
finally {
stmt.close();
rst.close();
poolMgr.freeConnection(conn);
}
}
}
The following is the messages i received from the log file:
poolMgr instantiated
conn instantiated
npe :null
From my understanding, it's seems like something wrong to the connection and statement, but i do not know why this happen, it works fine previously. Do you have any idea why this happen and how to overcome this problem?
I tried to uninstall and install my DB2, but the same thing still occurs. Can you help???
Thanks a lot and hope to hear from you soon...
regards..