Reputation: 37
I'm beginner in android develop. I have a oracle database in remote system and I want to connect database from my android app. I used below code for connect but I can't connect to it (with ojdbc14.jar library). /n have you Ideas???
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@//192.20.xx.xxx:1521/SHOP47";
Connection conn =
DriverManager.getConnection(url, "user", "pass");
conn.setAutoCommit(false);
Statement stmt = conn.createStatement();
ResultSet rset =
stmt.executeQuery("select count(1) from GOODS");
while (rset.next()) {
Toast.makeText(getBaseContext(),rset.getString(1).toString(), Toast.LENGTH_SHORT).show();
}
stmt.close();
}
catch(Exception e){
Log.d(TAG,e.getMessage());
}
Upvotes: 0
Views: 48
Reputation: 888
Actually, you shouldn't do this directly from an android application, because:
A better solution would be to use a service-oriented architecture where you will have at least two applications:
In Android, you can create a Restful Service Layer that will have methods for each service.
Upvotes: 2