This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark ""select top * ..." with Access" Watch ""select top * ..." with Access" New topic
Author

"select top * ..." with Access

yuki tanabe
Greenhorn

Joined: Aug 22, 2002
Posts: 4
Hi,

I'm having trouble executing a PreparedStatement against a MS Access database. The query string, taken using Eclipse debugger during runtime is:

and I do

where pstmtFetchPage is the PreparedStatement.

When I execute the statement, I get the following error:


I really can't see what I'm doing wrong. Any help is very much appreciated.

cheers.


Certified stress free!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Abe,
The database is complaining about the first question mark (the one after the keyword top.) In JDBC, you can't substitute just any part of the SQL in through a prepared statement. Basically, you can only put a value in (for the where clause.) You are going to need to build the first part of the statement dynamically.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
 
subject: "select top * ..." with Access
 
Similar Threads
Issue with Date insertion
Help with MS Access & Date
SQLException on connect
Retreiving data
In Access,Oracle8i PE ResultSet is not scrolling