I am trying to connect from Android application (2.2 - 4.3) to Oracle XE 10 with JDBC driver. I am using Eclipse and I added JDBC jar file to "libs" folder so It´s automatically in "Android private libraries". But after I run application in emulator it still throws ClassNotFoundException - oracle.jdbc.OracleDriver.
I have now only short testing code similar to this: https://stackoverflow.com/a/15756421/2922469, but for Oracle of course.
I searched in many answers here, but nothing help me to solve this problem. Could anyone help me please?
edit: I first tried classes12.jar, but there was some errors, so I added ojdbc6.jar downloaded directly from Oracle website.
TextView tv = (TextView)this.findViewById(R.id.textView3);
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection(url, user, pass);
String result = "Database connection success\n";
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from knihy");
ResultSetMetaData rsmd = rs.getMetaData();
while(rs.next()) {
result += rsmd.getColumnName(1) + ": " + rs.getInt(1) + "\n";
result += rsmd.getColumnName(2) + ": " + rs.getString(2) + "\n";
}
tv.setText(result);
}
catch(Exception e) {
e.printStackTrace();
tv.setText(e.toString());
}