• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Problem with DB2

Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm having problem in retriving records from the DB2 database. The follwing is my code:
String sql = "select * from user";

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 {
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...
Posts: 3892
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You appear to be using a "PoolManager" class that is of your own design -- this is not the J2EE/WebSphere way of obtaining a connection. My guess is that your pool manager doesn't work and is returning null, thus the NPE. However, without the code for the class, we couldn't give you any more help.
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic