private ProjectFile handleMDBFile ( InputStream stream ) throws Exception { File file = InputStreamHelper . writeStreamToTempFile ( stream , ".mdb" ) ; try { Class . forName ( "sun.jdbc.odbc.JdbcOdbcDriver" ) ; String url = "jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb);DBQ=" + file . getCanonicalPath ( ) ; Set < String > tableNames = populateTableNames ( url ) ; if ( tableNames . contains ( "MSP_PROJECTS" ) ) { return readProjectFile ( new MPDDatabaseReader ( ) , file ) ; } if ( tableNames . contains ( "EXCEPTIONN" ) ) { return readProjectFile ( new AstaDatabaseReader ( ) , file ) ; } return null ; } finally { FileHelper . deleteQuietly ( file ) ; } }
We have identified that we have an MDB file . This could be a Microsoft Project database or an Asta database . Open the database and use the table names present to determine which type this is .