File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Unable to get Statement Object. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Unable to get Statement Object." Watch "Unable to get Statement Object." New topic
Author

Unable to get Statement Object.

Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
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....


Sharing is learning
Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276
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.


Regards,
Jignesh

The Art Of Life Is To Know When To Be Useless And When To Be Useful - CHUANG TZU
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
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

Joined: Dec 28, 2004
Posts: 276
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.
Abhinav Gupta
Greenhorn

Joined: Apr 04, 2006
Posts: 3
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

Joined: Nov 28, 2001
Posts: 233
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to get Statement Object.