i wrote program to connect oracle database 11g for my android application to store values. My table name is names contains three fields. I imported ojdbc.jar file in to my project. After compiling program a log cat error displays like ” could not find the class oracle.jdbc.driver.OracleDriver() ” like this. Pls give one solution or is any other jar file i need to import?
package com.odbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import android.app.Activity;
import android.os.Bundle;
public class OdbcActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String a="karthick";
String b="vijay";
String c="vel";
try
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.2:1521:XE","system","mobile");
PreparedStatement pst=con.prepareStatement("insert into names(name1,name2,name3) values(?,?,?)");
pst.setString(1,a);
pst.setString(2,b);
pst.setString(3,c);
pst.executeUpdate();
}
catch(Exception e)
{
System.out.println("Exception:"+e);
}
}
}
Place the ojdbc.jar in libs/ directory under your android project.
See this page for a more detailed explanation of why you need to do this with r17.