سؤال

Die Datenbank 'C:\TEMP\derbyDB01' konnte nicht mit dem Klassenladeprogramm sun.misc.Launcher$AppClassLoader@253498 gestartet werden. Details können Sie der nächsten Ausnahme entnehmen.
    at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
    at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
    at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown Source)
    at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
    at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
    at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:579)
    at java.sql.DriverManager.getConnection(DriverManager.java:243)
    at Importer.getCon(Importer.java:88)

this is the part of the code, causing the exception:

private static final String jdbc_driver = "org.apache.derby.jdbc.EmbeddedDriver";
private static Connection conn = null;

public void importToDB(String DB_URL, String[] header, List<Data> dataList, File csv ) throws SQLException, ClassNotFoundException {
    stmt = null;
    ResultSet rs = null;
    String sql = null;
    String tablename = spl.getTableName(csv);

        Class.forName(jdbc_driver);

        if (conn == null) {

            conn = getCon(DB_URL);
        }

...

public static Connection getCon(String DB_URL) throws SQLException {

        System.out.println("Connecting to a selected database...");

        conn = DriverManager.getConnection(DB_URL);

        System.out.println("Connected successfully...");
        return conn;

    }

the String DB_URL is given to the method by taking it from a JTextfield. the URL I use is correct, because the program worked with it, before adding the GUI. it is: "jdbc:derby:C:\TEMP\derbyDB01"

So what is causing so much problems in here?

هل كانت مفيدة؟

المحلول 2

Sorry for taking so long to Update this.

Almost forgot I had it posted here. The problem was that I opened the database connection via an eclipse db plugin. When closing that plugin, it doesn't properly close the connection, which then produces in this exception when the program is trying do gain access again.

نصائح أخرى

According to Derby developer guide, you need to reverse the slashes in URL

jdbc:derby:c:/TEMP/derbyDB01
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top