aspose file tools*
The moose likes JDBC and the fly likes Too few paramters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Too few paramters" Watch "Too few paramters" New topic
Author

Too few paramters

Lex Wouda
Greenhorn

Joined: Mar 07, 2001
Posts: 22
Hi,
When I parse this code:
Select name frome employees where name="smith"; in MS-access, the result is, obviously, a field with the name smith (if it exists)
However, when I use former mentioned query in the following line
ResultSet rs = stmt.executeQuery(query);
I get a 'too few parameters, expected 1" error. DSN and other stuff is good because query 'select name from employees;' works fine.
I try'd PreparedStatement as was told somewhere else in this group, but then I'll get 'Driver does not support this function'.
Using Visual Age for Java 3.5 on W2K and trying to access MS-access2k, standard sun's jdbc-odbc driver.
any help is welcome,
grtz,
Lex
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
How are you building the statement?
What does the Query statement look like before you send it?


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Lex Wouda
Greenhorn

Joined: Mar 07, 2001
Posts: 22
I finally got it working using PreparedStatement.
Now I know, ms-access probably needs prepared statements.
This is working:
String query = "Select name From Employees Where name=?;";
PreparedStatement pst = con.prepareStatement(query);
pst.setString(1,request.getParameter("name"));
Building the string direct (" ....where name=\"" + name + " \";"; ) and passing it to a normal statement doesn't work.
Now I need to know how I can make the ResultSet updateable;
creation of the resultset via PreparedStatement doesn't give the possibillity to give params UPDATABLE etc. like creation via Statement does.
L.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Too few paramters