0

I am attempting to perform a simple query on a database in an android application. But the program crashes every time the method is performed. Does anyone have any suggestions on how to fix this?

Here is the error log message:

07-15 17:20:23.623: ERROR/AndroidRuntime(544): Uncaught handler: thread main exiting due to uncaught exception 07-15 17:20:23.643: ERROR/AndroidRuntime(544): java.lang.VerifyError: com.mysql.jdbc.MysqlIO 07-15 17:20:23.643: ERROR/AndroidRuntime(544): at com.mysql.jdbc.Connection.createNewIO(Connection.java:2771) 07-15 17:20:23.643: ERROR/AndroidRuntime(544): at com.mysql.jdbc.Connection.(Connection.java:1555) 07-15 17:20:23.643: ERROR/AndroidRuntime(544): at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285) 07-15 17:20:23.643: ERROR/AndroidRuntime(544): at java.sql.DriverManager.getConnection(DriverManager.java:191) 07-15 17:20:23.643: ERROR/AndroidRuntime(544): at java.sql.DriverManager.getConnection(DriverManager.java:226)

Here is my connection:

String url = "jdbc:mysql://192.126.0.1:3306/";
        String db = "db";
        String driver = "com.mysql.jdbc.Driver";
        String table = "table";
        Connection conn = null;

        try {
            Class.forName(driver);
            try {
                conn = DriverManager.getConnection(url+db,"root","");

                conn.close();

            } catch (SQLException s) {
                s.printStackTrace();
            }
        } catch (ClassNotFoundException cnfe){
            System.out.println("ERROR");
        }

2 Answers 2

1

You have a different version of the JDBC driver in your compile time environment, and a different one in your runtime environment. Scan your disk and device for mysql-connector*.jar and make sure that you have only one around.

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

2 Comments

I am using an Emulator. How do I scan the runtime environment?
@scriptdiddy - Use busybox find -name 'mysql*jar' command. Or see also the answer here.
0

Im working on an android app with online mysql db as well. I think you cant connect it directly like in java applications. You should write php files and put them on a server. They will connect to the db and send you data inJSON...

Comments

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.