• Post Reply Bookmark Topic Watch Topic
  • New Topic

prepared statement in java

 
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.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!