File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Error while using PreparedStatement Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Error while using PreparedStatement" Watch "Error while using PreparedStatement" New topic
Author

Error while using PreparedStatement

Divya U.S
Greenhorn

Joined: Jul 11, 2007
Posts: 1
Hello,

I am using netbeans 5.5 and SQL2000 server db.
following error is coming
java.sql.SQLException: Driver does not support this function
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeQuery(JdbcOdbcPreparedStatement.java:115)

my code is given below.
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbcdbc:MyDataSource","sa","sajandev");
char[] pass=TxtPass.getPassword();
String passwd=new String(pass);
this.TxtUser.getText() + "' " + and UserPass="'+ passwd ;
String str="select * from UserLogin where UserId=? and UserPass=?";

PreparedStatement ps=con.prepareStatement(str);
String user=this.TxtUser.getText();
ps.setString(1,user);
ps.setString(2,passwd);
lblMsg.setText(str);
ResultSet rs=ps.executeQuery(str);
str="";
if(rs.next())
{
lblMsg.setText("Login Successful!!");
}
else
{
lblMsg.setText("Login Failes!!");
}
con.close();
rs.close();
ps.close();
}
catch(Exception e)
{
System.out.println("SQL Exception: "+ e.toString());
e.printStackTrace();
}

Please give me a solution for this as soon as possible.
I've to create an application submission date is Aug 2.
pls help me...
divya
subodh gupta
Ranch Hand

Joined: Jul 23, 2007
Posts: 203
just write ps.executeQuery(); without any argument your code will run.


http://subodh-gupta.blogspot.com
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Error while using PreparedStatement
 
Similar Threads
missing expression error
Prepared Statement problem in my servlet's data manager
To show the Error message at the login.jsp page using servlet
PreparedStatement error shown
Using JDBC how to put single quotes(')