• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Error while using PreparedStatement

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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("jdbc:odbc: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
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just write ps.executeQuery(); without any argument your code will run.
 
reply
    Bookmark Topic Watch Topic
  • New Topic