Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PreparedStatement error

 
Tiago Hillebrandt
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Paul Clapham
Sheriff
Posts: 21149
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic