Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

prepared statement in java  RSS feed

 
kshitiz khandelwal
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String query = "SELECT * FROM pdt1 WHERE pid = ? , pname = ?";
PreparedStatement ps = con.prepareStatement(query);
ps.setInt(1, 5);
ps.setString(2,"Xyz");
System.out.println("ps.set executed");

ResultSet rs = ps.executeQuery();// exception occurs here.


output:

Exception in thread "main" java.sql.SQLException: ORA-00933: SQL command not properly ended
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably meant to use "AND" instead of the comma; that would make it proper SQL.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!