Search code examples
sqlitemobileoracle-adfjdeveloper

Local SQLite connection on JDeveloper


I'm completely new to ADF Mobile and have previously made a connection to and SQLite DB with NetBeans. I'm replicating the code, and I'm getting an Import java.sql.DriverManager not found error (in bold).

package mobile;

import java.sql.Connection;
**import java.sql.DriverManager;**
import java.sql.*;

public class Connect {
public Connect() {
    super();
}


public class JavaConnect {

    static Connection conn = null;
    static ResultSet rs = null;
    static PreparedStatement pst = null;

    public static Connection DBConnect() {

        try {
            Class.forName("org.sqlite.JDBC");
            conn = DriverManager.getConnection("jdbc:sqlite:AlternativeIdentification.sqlite");
            System.out.println("Connection established");
            return conn;
        } catch (Exception ex) {
            System.out.println("Error: " + ex);
            return null;
        }

    }

Solution

  • Download https://code.google.com/p/sqlite-jdbc/. Then in your JDeveloper go to Tools>ManageLibraries and create a new library. Check the 'DeployedByDefault' checkbox there and add the JAR in the library (>addEntry). Then go to your Project, go to ProjectProperties and then to Libraries and Classpath and click on Add Library to add your new library to your project. Rebuild your project or restart JDeveloper in the worst case and you should be fine.