jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes PreparedStatement error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "PreparedStatement error" Watch "PreparedStatement error" New topic

PreparedStatement error

Tiago Hillebrandt

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: 1082

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.


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

Joined: Oct 14, 2005
Posts: 19973

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
It's not a secret anymore!