0

In an old Java application I have the following code to connect to a SQL database and use it for some queries:

private Connection dbConnection = null;
System.setProperty("derby.system.home", "C:\\");
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
String strUrl = "jdbc:derby:BOOKSDB";
dbConnection = DriverManager.getConnection(strUrl);
Statement stmt = dbConnection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM BOOKS");

Is there any chance to use it on Android? The documentation say that it is possible in general, isn't it? But how can one use it?

Or would it be easier to change this part so that it uses SQLite instead? I think this is much work to do because with SQLite, you always have a cursor instead of a ResultSet and so on ...

1 Answer 1

1

You can use JDBC on android, provided you supply a JDBC driver that will run on Android. There is a open source pure-Java jdbc driver that should run on Android (although I haven't tried it myself). You will have to adapt the JDBC URL to connect to the sqlite db; that way you can use the local android database while making few changes to your data access code.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much! I ended up using SQLDroid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.