aspose file tools*
The moose likes JDBC and the fly likes PreparedStatement error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "PreparedStatement error" Watch "PreparedStatement error" New topic
Author

PreparedStatement error

Tiago Hillebrandt
Greenhorn

Joined: Jun 07, 2008
Posts: 19
I have created a method to verifies the number of lines from a mysql database table, but is happens this error:

description The server encountered an internal error () that prevented it from fulfilling this request.

exception org.apache.jasper.JasperException: java.lang.NullPointerException


Debugging, on try sets the prepareStatement to pst variable the error happens.

What is the error? The table havens 3 registers!

Sorry for english!


[ June 07, 2008: Message edited by: Tiago Hillebrandt ]
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081


this.pst = this.con.prepareStatement("SELECT count(*) AS count FROM ?;");


1. Do not set table name as bind variable.

2. you need not to add semi colon in query.


Thanks,
Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

And as for the NullPointerException, that means that the variable "con" is null. Perhaps your mysql.connect() tries to set it to something but fails to do so.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PreparedStatement error