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