2012-03-19 15 views
0

私はアンドロイドアプリケーションのためにODBC接続を接続したいと思います。私のプログラムでは、Oracleデータベース11gを使用しています。テーブル名はサンプルです。私は、エミュレータを閉じるプログラムを実行した後、値を格納することができなかったデータベースを開きます。私のプログラムや接続文字列に1つの解決策や変更を加えてください。android odbc connection

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); 

    } 
} 
    } 
+0

あなたの指示に感謝します[アンドロイドjdbc odbc接続](http://stackoverflow.com/questions/9440532/android-jdbc-odbc-connection) – Esailija

答えて

0

いけない、それはあなたのOracleが稼働しているシステムのIPアドレスを追加し、実際のデバイスまたはemulator.Pleaseを表すようれたconnectionStringでlocalhostを使用。

+0

の重複。それは私がたくさんの –