• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
A "dutch baby" is not a baby. But this tiny ad is baby sized:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic