Problem with Ms-Access database

2012-03-11
2013-05-29
  • Clayton Bonelli

    Clayton Bonelli - 2012-03-11

    Using the following Java code the Ms-Access database is easily accessed:

    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String URL = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Temp/MyTest.mdb;}";
    Connection con = DriverManager.getConnection(URL, "admin", "mypassword");
    try {
    ResultSet rs = con.createStatement().executeQuery(
    "select * from auxComunCobertNascMULT");
    while (rs.next()) {
    System.out.println(rs.getInt("id")
    + rs.getString("name"));
    }
    } finally {
    con.close();
    }
    } catch (Exception e) {
    System.out.println("Error: " + e);
    }

    So, I created the following msaccess.properties file:

    description=MS-ACCESS
    driver=sun.jdbc.odbc.JdbcOdbcDriver
    connectionSpec=jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=<db>;}

    And I created the following ANT task:

        <target name="diagram">
           
            <java jar="C:/Temp/schemaSpy_5.0.0.jar"
                output="C:/Temp/schemaspy-out.log"
                error="C:/Temp/schemaspy-error.log"
                fork="true">
               
                <arg line="-t C:/Temp/msaccess"/>
                <arg line="-db C:/Temp/MyTest.mdb"/>
                <arg line="-u admin"/>
                <arg line="-p mypassword"/>
                <arg line="-o C:/Temp"/>
                <arg line="-norows"/>
               
            </java>
           
        </target>   

    After to run the ANT task I got the foolowing error (schemaspy-error.log):

    net.sourceforge.schemaspy.model.Table$1ColumnInitializationFailure: Failed to collect column details for table 'auxComunCobertNascMULT' in schema 'null'
    at net.sourceforge.schemaspy.model.Table.initColumns(Table.java:295)
    at net.sourceforge.schemaspy.model.Table.<init>(Table.java:88)
    at net.sourceforge.schemaspy.model.Database$TableCreator.createImpl(Database.java:1003)
    at net.sourceforge.schemaspy.model.Database$TableCreator.create(Database.java:999)
    at net.sourceforge.schemaspy.model.Database.initTables(Database.java:250)
    at net.sourceforge.schemaspy.model.Database.<init>(Database.java:71)
    at net.sourceforge.schemaspy.SchemaAnalyzer.analyze(SchemaAnalyzer.java:211)
    at net.sourceforge.schemaspy.Main.main(Main.java:42)
    Caused by: java.sql.SQLException: No data found
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7138)
    at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3907)
    at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5698)
    at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:354)
    at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:411)
    at net.sourceforge.schemaspy.model.TableColumn.<init>(TableColumn.java:70)
    at net.sourceforge.schemaspy.model.Table.addColumn(Table.java:369)
    at net.sourceforge.schemaspy.model.Table.initColumns(Table.java:284)
    … 7 more

    Thanks for any help.

    Clayton

     
  • Clayton Bonelli

    Clayton Bonelli - 2012-03-12

    I did the checkout of source code (from SVN) and I discovered that the problem (an Exception) ocorred with the statement:

    String tmp = rs.getString("COLUMN_NAME"); // TableColumn class

    apparently an error occurs when that command is executed twice with MS ACCESS databases.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks