vendredi 2 octobre 2015

Sqlite database not working in .jar executable but works in eclipse

I have this database for my game, it works perfectly in Eclipse but when i make .jar executable it just crashes and if i remove System.exit(0) ; the game works perfectly but database just doesn't work! Thanks in advance for help!

private Connection c = null;
private Statement stmt = null;
public void updatetable()   {
    try{

        Class.forName("org.sqlite.JDBC");
        c = DriverManager.getConnection("jdbc:sqlite:Resources/Data/gameData.db");
        c.setAutoCommit(false);
        stmt = c.createStatement();

        ResultSet rs = stmt.executeQuery( "SELECT * FROM SCOREDATA ORDER BY score DESC LIMIT "+MAX_ROWS);

        int row = 0 ;
        while(rs.next()){
            list[row][0] = rs.getString("name");
            list[row][1] = rs.getString("score");

            row++;
        }


        rs.close();
        stmt.close();
        c.commit();
        c.close();
        fireTableDataChanged();

    } catch (Exception e) {
        e.printStackTrace();
        System.err.println( e.getClass().getName() + ": " + e.getMessage() );
        System.exit(0);
    }

}

Aucun commentaire:

Enregistrer un commentaire