Menu

UCanAccess does not show tables created after DB was opened (yet they can still be queried)

Help
2015-12-01
2015-12-05
  • RavenAtSafe

    RavenAtSafe - 2015-12-01
    1. Open an Access datatabase using UCanAccess
    2. Call connection.getMetaData().getTables() to get list of tables
    3. Without closing UCanAccess application, use another process to write a new table to the opened database
    4. Again, call connection.getMetaData().getTables() to get list of tables the new table will not be exposed
    5. Yet, you can still execute a SELECT * in UCanAccess against the new table

    Would it be reasonable for connection.getMetaData().getTables() to pick up new tables as they are added?

     
  • RavenAtSafe

    RavenAtSafe - 2015-12-01

    Actually, you might even see this with two different connection objects in the same process, implying that some shared caching is going on...

     
  • Marco Amadei

    Marco Amadei - 2015-12-01

    It seems reasonable (bugs do exist) but your final assumption isn't. The only cache is an in memory table in the mirror db you're always speaking with. Second part tomorrow, here it is night now.

     

    Last edit: Marco Amadei 2015-12-01
  • Marco Amadei

    Marco Amadei - 2015-12-01

    What if you get metadata after having executed  a query (any query)?

     
  • Marco Amadei

    Marco Amadei - 2015-12-02

    So, as I said your final assumption about cache is wrong(and a bit misleading).
    To get evidence of this execute:

     public static void main(String[] args) throws SQLException {
                    String dbFileName = "ConcurrTest.accdb";
                    Connection conn1 = DriverManager.getConnection("jdbc:ucanaccess://" + dbFileName + ";newdatabaseversion=V2010" );
                    Connection conn2 = DriverManager.getConnection("jdbc:ucanaccess://" + dbFileName + ";newdatabaseversion=V2010" );
                    Statement st = conn1.createStatement(); 
                    st.execute("CREATE TABLE ConcurrTest2 ([ID] COUNTER PRIMARY KEY, [TextField] TEXT(255))");
                    System.out.println("Table created");
                    ResultSet rs=conn2.getMetaData().getTables(null, null, "ConcurrTest2", null);
                    System.out.println(rs.next());
          }
    

    The first one assumption is correct instead, the trigger to check for an external update is a "database touch" so the execution of a statement, but I omitted to do it for internal metadata query. So if you had executed a query like select * from dual before conn.getMetaData().getTables it would have worked. Obviously it's a bug (and bugs do exist). Fix will be in the 3.0.3.

     

    Last edit: Marco Amadei 2015-12-02
  • RavenAtSafe

    RavenAtSafe - 2015-12-03

    Fix will be in the 3.0.3.

    Awesome! Thank you

     
  • Marco Amadei

    Marco Amadei - 2015-12-05

    Fixed in svn trunk.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.