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

Driver does not support this function

15 views
Skip to first unread message

bill turner

unread,
Oct 26, 2006, 2:04:41 PM10/26/06
to
Hi All,

I cannot seem to figure this out. When I use a PreparedStatement, I get
a SQLException. If, rather, I just replace the variable and use
Statement, it works just fine. I am trying to run against ODBC to an
Access db. I've tried searching the web, but see little, out of the
millions of hits, that seem to apply. Any ideas?

Here is the query. Note that the I surrounded the ? with single quotes
when using Statement.

"SELECT " +
" PhotoList.Pick, " +
" PhotoList.Type, " +
" PhotoList.ItemNumber AS ItemNbr, " +
" PhotoList.ItemDescription AS ItemDesc, " +
" PhotoList.Brand, " +
" PhotoList.VendorAliasPartNumber, " +
" PhotoList.BinLocation, " +
" PhotoList.Width, " +
" PhotoList.Length, " +
" PhotoList.Height, " +
" PhotoList.Wt AS Weight, " +
" PhotoList.PhotoId " +
"FROM PhotoList " +
"WHERE PhotoList.ItemNumber = ?";


Here is the code. It fails when setting the ResultSet (executing the
query).

public boolean get(String itemNbr) throws SQLException
{
System.out.println("ItemPhotoList.get(String itemNbr=[" + itemNbr +
"])");
this.stmt.setString(1, itemNbr);
try {
this.resultSet = stmt.executeQuery(query);
}
catch (SQLException e)
{
System.out.println(e.getMessage());
System.out.println(e.getSQLState());
System.out.println(e.getErrorCode());
e.printStackTrace();
System.exit(1);
}

Here is the console output.

ItemPhotoList.get(String itemNbr=[0116-00102])
java.sql.SQLException: Driver does not support this function
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeQuery(Unknown
Source)
at com.rjmdental.axapta.input.ItemPhotoList.get(ItemPhotoList.java:57)
at com.rjmdental.axapta.extract.Extract.extract(Extract.java:222)
at com.rjmdental.axapta.extract.Extract.run(Extract.java:108)
at com.rjmdental.axapta.ItemMain.extract(ItemMain.java:184)
at com.rjmdental.axapta.ItemMain.run(ItemMain.java:163)
at com.rjmdental.axapta.ItemMain.main(ItemMain.java:423)
Driver does not support this function
IM001
0

If you have any ideas or suggestions, I would appreciate it.

TIA

Bill

Lee Fesperman

unread,
Oct 27, 2006, 5:31:04 PM10/27/06
to
bill turner wrote:
> I cannot seem to figure this out. When I use a PreparedStatement, I get
> a SQLException. If, rather, I just replace the variable and use
> Statement, it works just fine. I am trying to run against ODBC to an
> Access db. I've tried searching the web, but see little, out of the
> millions of hits, that seem to apply. Any ideas?
>
> Here is the query. Note that the I surrounded the ? with single quotes
> when using Statement.

You did? You should not surround the ? with single quotes, and you should have shown
what you actually did.

You omitted relevant code here -- creating the PreparedStatement. However, the code you
did show:

this.resultSet = stmt.executeQuery(query);

... indicates you are misusing PreparedStatement. You should be using the no-args
version of executeQuery() and passing the query string when you create the
PreparedStatement. The proper sequence is something like this:

this.stmt = new PreparedStatement(query);

this.stmt.setString(1, itemNbr);
this.resultSet = stmt.executeQuery();

Note the use of the no-args executeQuery(). This is all described in the basic JDBC
docs.

Also, don't miss the comment above about surrounding ? with single quotes.

That said, I can't guarantee that this will work with Access. The JDBC/ODBC driver weak,
and Access is weak. Replace both of those, and you'll be in great shape.

--
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)

0 new messages