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 / Databases / May 2006

Tip: Looking for answers? Try searching our database.

Two more Access/Java questions

Thread view: 
Rhino - 30 May 2006 17:01 GMT
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


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.