可用ODBC加DSN连接
首先在你的用户机里加一个系统DSN,指向oracle数据库
然后用如下代码
String MM_conn_DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
String MM_conn_USERNAME = "";
String MM_conn_PASSWORD = "";
String MM_conn_STRING = "jdbc
dbc:dsnORACLE";<<----此处写DSN名称,在odbc:后面
String Recordset1__MMColParam = "1";
String Recordset1__MMColParam2 = "2";
Driver DriverRecordset1 = (Driver)Class.forName(MM_conn_DRIVER).newInstance();
Connection ConnRecordset1 = DriverManager.getConnection(MM_conn_STRING,MM_conn_USERNAME,MM_conn_PASSWORD);
PreparedStatement StatementRecordset1 = ConnRecordset1.prepareStatement("SELECT * FROM register WHERE UserName = '" + Recordset1__MMColParam + "' and PassWord='"+Recordset1__MMColParam2+"'");