i can't use PreparedStatement with parameterers because of strange "java.lang.NullPointerException: null"

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

i can't use PreparedStatement with parameterers because of strange "java.lang.NullPointerException: null"

leks
i can't use PreparedStatement with parameterers because of strange "java.lang.NullPointerException: null" error

The exception occures at following line:
java.sql.PreparedStatement st = conn.prepareStatement(sql);

please note 'conn' object is not null and 'sql' is also not null.

The exception may occur or not depending on number of parameters in prepared statement and order of parameteres

for example, this sql works fine:
"select  id, adate"
 from DATA v where 1=1 and id not in (1,0,10000)"
 and id=?"

and this works fine
"select  id, adate"
 from DATA v where 1=1 and id not in (1,0,10000)"
 and  adate>? and adate<?"

and this works fine:
"select  id, adate"
 from DATA v where 1=1 and id not in (1,0,10000)"
and  adate>?  and id=?"


but this sql causes exception:

"select  id, adate"
 from DATA v where 1=1 and id not in (1,0,10000)"
 and id=?"
 and  adate>? and adate<?"


here is my code

  Class.forName("org.luciddb.jdbc.LucidDbClientDriver").newInstance();
  java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:luciddb:http://192.168.254.166","sa","");
  sql = xxxxx
  java.sql.PreparedStatement st = conn.prepareStatement(sql); - Exception is here!!!


Please advise,
thank you.

Leks
Loading...