NullPointerException when trying to PreparedStament.setString()
Posted by: Tom Coupland
Date: September 15, 2005 04:55AM

Hi all,

Have been using prepared statements in my proj for a while and have enjoyed quite abit of success with them, but today i decided to changed the order of things abit and now they won't work! Heres my code snippet


public ResultSet executeStatement(String[] args) throws SQLException{
synchronized(myStatement){
try{
for(int i=0;i<args.length;i++){
log.info("Setting statement var "+(i+1)+" to "+args);
myStatement.setString(i+1, args);
}
return myStatement.executeQuery();


When it runs i now get this


java.lang.NullPointerException at com.mysql.jdbc.ServerPreparedStatement.getBinding(ServerPreparedStatement.java:733) at com.mysql.jdbc.ServerPreparedStatement.setString(ServerPreparedStatement.java:1738) at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.setString(WrappedPreparedStatement.java:406) at meta.database.PersistentDatagram.executeStatement(PersistentDatagram.java:101)


Can anyone shed some light on this for me? Would really appreciate it!

Cheers

Tom

Options: ReplyQuote


Subject
Written By
Posted
NullPointerException when trying to PreparedStament.setString()
September 15, 2005 04:55AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.