kengoudsward
asked on
how to query MSysObjects (using Java)
I have a Java app which reads .mdb files like so:
Class.forName("sun.jdbc.od bc.JdbcOdb cDriver");
// we are using the direct connection method rather than the DNS method
String database = "jdbc:odbc:Driver={Microso ft Access Driver (*.mdb)};DBQ=";
database+= filename.trim() + ";DriverID=22;READONLY=tru e}"; // add on to the end
Connection con = DriverManager.getConnectio n( 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,nu ll,"%",nul l);
... 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!
Class.forName("sun.jdbc.od
// we are using the direct connection method rather than the DNS method
String database = "jdbc:odbc:Driver={Microso
database+= filename.trim() + ";DriverID=22;READONLY=tru
Connection con = DriverManager.getConnectio
ResultSet rs;
DatabaseMetaData metaData = con.getMetaData();
// find out what tables and queries are in the database, and display their names
rs = metaData.getTables(null,nu
... 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!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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!
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!
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
ahh well, next time I'll be more specific :)
thanks for the question,
John
hth
John