Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

querying an access table

0 views
Skip to first unread message

Justin

unread,
Nov 28, 2006, 1:18:22 PM11/28/06
to
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

unread,
Nov 28, 2006, 1:43:32 PM11/28/06
to
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.

Justin

unread,
Nov 28, 2006, 1:57:06 PM11/28/06
to
and finally, the wild card character must be a "%" not an asterisk like
in Access.
0 new messages