• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to get Statement Object.

 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
One of the existing application which is used over a period of time causing a problem all of sudden.
When investigated i found the Statment object is not returned from the Connection object.
System.out.println("Connection is closed " +conn.isClosed() );
//isClosed() is returing false, which making me to belive connection is fine.
Statement st =conn.createStatement(); //st is null

What whould be possible reason createStatement method return null...
Thanks in advence for help....
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Arun,

System.out.println("Connection is closed " +conn.isClosed() );
//isClosed() is returing false, which making me to belive connection is fine



Instead of this one check out if (conn == null) if yes then conenction might not have established.

As per my knowledge u might not get the statement object because the connection object is not obtained,you can try out the check for connection object like above mentioned ie for null.
 
Arun Boraiah
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jignesh,
Actually if connection was null, then when i tried createStatement() on connection object i should have got null pointer exception. However i tried your condition and i found that connection is not null.
Any other inputs....
Thanks
 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Arun,

If u can , please paste some of ur code which is creating problem??
By looking at the code somebody can help u in less time.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Arun,

Please specify the problem enviornment clearly.
Like which database, driver, App Server etc u are using ..
Becuase there may be some problem in the enviorment.
Also paste some code snipplet you are trying out..


thanks,
Abhinav
 
Arun Boraiah
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
Thanks for your response.
The problem is resolved, The cause for the problem was the classpath.
I mean the driver present in the classpath was not one expected. Hence on correcting the classpath, application is working fine.
Regards
Arun
 
reply
    Bookmark Topic Watch Topic
  • New Topic