2012-02-22 12 views
0
私はアンドロイドのアプリケーションへのOracle 11gデータベース用のODBC接続を接続したい

。私のプログラムでは、Oracleデータベースに2つの文字列を格納したいと考えています。私のテーブル名はname1です。テーブルを開くときにプログラムを実行した後、値を保存できませんでした。アンドロイドとODBC

package com.odbc; 

    import java.sql.Connection; 
    import java.sql.DriverManager; 
    import android.app.Activity; 
    import android.os.Bundle; 
    import java.sql.*; 

    public class OdbcdemoActivity extends Activity { 
     /** Called when the activity is first created. */ 
     @Override 
     public void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.main); 
      try 
      { 
     String first="kumar"; 
     String last="vijay"; 
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 

     Connection con=DriverManager.getConnection("jdbc:odbc:student","system","water"); 
     PreparedStatement pst=con.prepareStatement("insert into student values(?,?)"); 
     pst.setString(1,first); 
     pst.setString(2,last); 
     pst.executeUpdate(); 
    } 
    catch(Exception e) 
    { 
     System.out.println("Exception:"+e); 
    } 

答えて

0

あなたのテーブル名はname1ですが、あなたはstudentにデータを挿入していますか?

は、次のことを試してください。

Connection con=DriverManager.getConnection("jdbc:odbc:student","system","water"); 
    PreparedStatement pst=con.prepareStatement("insert into name1 (colname1, colname2) values(?,?)"); 
    pst.setString(1,first); 
    pst.setString(2,last); 
    pst.executeUpdate(); 

希望これは

を支援します