简体   繁体   中英

Using Java, How can I list and print all Queries in a MS-Access 2003 mdb file?

I am able to create a java.sql.Connection object and get table data:

DatabaseMetaData metaData = connection.getMetaData();

String [] tableTypes = {"Table"};
ResultSet rs = metaData.getTables(null, null, null, tableTypes);

if (rs != null) {
   while (rs.next()) {
      String tableName = rs.getString("TABLE_NAME");
      // Do some further table analysis
   }
}

How do I get the Queries saved in the mdb file as well? (specifically, their names, and the SQL statements that they are made of)

Thanks!

Use Jackcess :

Database db = DatabaseBuilder.open(new File("access.mdb"));
for (Query query : db.getQueries()) {
    System.out.println(query.getName() + ": " + query.toSQLString());
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM