Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2006

Tip: Looking for answers? Try searching our database.

querying an access table

Thread view: 
Justin - 28 Nov 2006 18:18 GMT
I followed the tutorial here
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2691&lngWId=2
to gain connectivity to an MS Access database.  I generated a query
within access and the inserted it into my java code.

the query is show below:

SELECT demographics.sSN, demographics.lastName, demographics.firstName
FROM demographics
WHERE (((demographics.lastName) Like "Lo*"));

This query works perfectly when run in access.  However, when I run it
in Java, it causes the following exception:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too
few parameters. Expected 1.
       at
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
       at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
       at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
       at
sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
       at
sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253)

When I remove the criteria from the query (ie WHERE
(((demographics.lastName) Like "Lo*"));) I can get the data to return,
but naturally, it returns all entries in the database.

As always, any help is greatly appreciated
Justin - 28 Nov 2006 18:43 GMT
I have partially figured this out.  In the "WHERE" statement, single
quotes must be used instead of double quotes.  However, use of the wild
card character (*) does not work.  It only returns exact matches.

> I followed the tutorial here
> http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2691&lngWId=2
[quoted text clipped - 26 lines]
>
> As always, any help is greatly appreciated
Justin - 28 Nov 2006 18:57 GMT
and finally, the wild card character must be a "%" not an asterisk like
in Access.

> I have partially figured this out.  In the "WHERE" statement, single
> quotes must be used instead of double quotes.  However, use of the wild
[quoted text clipped - 30 lines]
> >
> > As always, any help is greatly appreciated


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.