vendredi 5 juin 2015

Proguard Breaks Database Connection

My application uses a database based on sqlite-jdbc. When I generate the runnable jar file, connecting to my database works fine however if I let Proguard process my application, it breaks the database connection.

The following code establishes a connection with the database file's path submitted. When using Proguard, the message "Got connection!" is never printed hence getConnection() is stuck.

import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;

private void loadDatabase(String databaseName) throws SQLException
{
    String databaseLibrary = "jdbc:sqlite:";

    JOptionPane.showMessageDialog(null, "Getting connection...");
    Connection databaseConnection = DriverManager.getConnection(databaseLibrary
            + databaseName);
    JOptionPane.showMessageDialog(null, "Got connection!");

    // ...
}

Only if the Shrink and Obfuscate options are disabled in Proguard the database connectivity does not break after processing.

Any ideas on how this can be fixed and why this happens?

Aucun commentaire:

Enregistrer un commentaire