• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while using PreparedStatement

 
Divya U.S
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just write ps.executeQuery(); without any argument your code will run.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic