1
我想连接odbc连接到我的android应用程序。我的数据库是Oracle 10g。在我的代码中,我的表名是世界。在编译我的程序并关闭在oracle数据库中的模拟器打开表后,值不能被存储android jdbc odbc连接
我编译正常的javac编译器在cmp中的相同编码提示值应该存储,如果我编译android应用程序在eclipse ide中值无法存储。请给我一个解决方案或任何更改我的代码 在此先感谢 包com.odbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import android.app.Activity;
import android.os.Bundle;
import android.R.id;
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);
try
{
String country="india";
String city="delhi";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:world","system","love");
PreparedStatement ps=con.prepareStatement("insert into world(country,city) values(?,?)");
ps.setString(1,country);
ps.setString(2,city);
ps.executeUpdate();
}
catch(Exception e)
{
System.out.println("Exception:"+e);
}
}
}
请参考我的回答对您的其他类似的帖子: http://stackoverflow.com/questions/9834056/android-odbc-connection-for-oracle-10g – 2012-04-10 21:03:47