Solved

how to query MSysObjects (using Java)

Posted on 2003-12-08
4
1,373 Views
Last Modified: 2007-12-19
I have a Java app which reads .mdb files like so:

       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        // we are using the direct connection method rather than the DNS method
        String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
        database+= filename.trim() + ";DriverID=22;READONLY=true}"; // add on to the end
        Connection con = DriverManager.getConnection( database ,"","");
        ResultSet rs;
        DatabaseMetaData metaData = con.getMetaData();
        // find out what tables and queries are in the database, and display their names
        rs = metaData.getTables(null,null,"%",null);

... which works great, however

I want to query against the system tables in the .mdb, specifically MSysObjects and MSysQueries to get som more structural info, but I get error:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Records can not be read; no read permission on 'MSysObjects'.

from the line:
Statement s = con.createStatement();
ResultSet rs_test = s.executeQuery("SELECT * FROM MSysObjects");

I am sure I solved this problem befor by tweaking a setting in Access, but I can't  remember how I did it. I have enabled viewing of the hidden and system tables, but this did not solve it. any help would be great!
0
Comment
Question by:kengoudsward
  • 3
4 Comments
 
LVL 10

Expert Comment

by:jobrienct
ID: 9902312
this thread appears to describe your problem quite well, albeit from a coldfusion perspective, the issue is securty settings i believe, read down past the original answer.

hth

John
0
 
LVL 10

Accepted Solution

by:
jobrienct earned 400 total points
ID: 9902314
0
 

Author Comment

by:kengoudsward
ID: 9909451
John, Thanks for the help
the thread you pointed me to said to...

Open up the database in Access, go to Tools, Options, View and select Hidden
and System objects.  

... which I had already done and wasn't the problem, but it was close. After a bit more playing around (and some sleep, and a new day)

I went to Tools, Security, User and Group Permissions
where I gave read permissions to all users and groups on the tables of interest; now it works!
0
 
LVL 10

Expert Comment

by:jobrienct
ID: 9909790
sorry, you read me wrong - i told you to scroll down passed the accepted answer a bit to where they talked about the security settings.

ahh well, next time I'll be more specific :)

thanks for the question,

John
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now