0
我想爲我的android應用程序連接odbc連接。在我的程序中,我使用的是Oracle數據庫11g,而我的表名是示例。我運行程序關閉模擬器後打開數據庫的值不能被存儲。請給我一個解決方案或我的程序或連接字符串中的任何更改。android odbc連接
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 first="vijay";
String last="kumar";
try
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","vijay");
PreparedStatement pst=con.prepareStatement("insert into sample(first,last) values(?,?)");
pst.setString(1,first);
pst.setString(2,last);
pst.executeUpdate();
}
catch(Exception e)
{
System.out.println("Exception:"+e);
}
}
}
[android jdbc odbc連接]可能重複(http://stackoverflow.com/questions/9440532/android-jdbc-odbc-connection) – Esailija 2012-07-16 18:34:56