Does anyone know why I am getting -1 as a return code from commands like
DROP TABLE and CREATE TABLE? I am using an Access 2002 database with the
sun.jdbc.odbc.JdbcOdbcDriver driver in rt.jar. I am using JDK 1.5.0_06.
The commands appear to be working correctly. For example, the table existed
and was accessible before I executed DROP TABLE, then was gone after I ran
the DROP TABLE. I was using a Statement object and, according to the API,
the executeUpdate() method should return the number of rows inserted,
updated, or deleted if the command inserted, updated, or deleted rows or 0
if the command was anything else. The API doesn't state any conditions under
which a command should return -1.
What is Access or the driver trying to tell me by giving me a -1 as the
result of executeUpdate()?
--
Also, am I correct in believing that Jet SQL, the dialect of SQL used by
Access, does not support the GRANT command? I was trying to do a "GRANT ALL
on myTable to PUBLIC" within my Java program but got errors suggesting that
the GRANT command was not one recognized by the driver or Access. I don't
recall the message now and have already deleted the code, otherwise I'd
simply rerun it and give you the exact message.

Signature
Rhino
Bjorn Abelli - 31 May 2006 10:07 GMT
"Rhino" wrote...
> Does anyone know why I am getting -1 as a return code from commands like
> DROP TABLE and CREATE TABLE? I am using an Access 2002 database with the
[quoted text clipped - 7 lines]
> rows or 0 if the command was anything else. The API doesn't state any
> conditions under which a command should return -1.
Nope, according to the documentation it should return 0...
> What is Access or the driver trying to tell me by giving me a -1 as the
> result of executeUpdate()?
My best guess is that it simply forwards what it *thinks* is the number of
affected rows, but as DDL statements doesn't take any rows into
consideration, I guess the ODBC driver returns the constant for
SQL_NULL_DATA (-1).
Just a guess, but anyway...
> --
>
[quoted text clipped - 4 lines]
> don't recall the message now and have already deleted the code, otherwise
> I'd simply rerun it and give you the exact message.
It does, but the documentation for Access 2000 says:
"The GRANT and REVOKE statements can be executed only through the Jet OLE DB
provider and ADO. They will return an error message if used through the
Access SQL View user interface or DAO."
http://tinyurl.com/4gk8
AFAIK, the ODBC-driver for Access doesn't use any underlying OLE DB or ADO
provider, and I guess they haven't changed that restriction in Access 2002.
/// Bjorn A