处理oracle协议适配器错误
景象:jdbc连接oracle817 for Linux出现适配器错误,sqlplus连接正常。
方法:编辑init.ora文件屏蔽
mts_dispatchers = "(PROTOCOL=TCP)(SER=MODOSE)"
重新启动oracle。
import java.sql.*;import java.lang.*;import java.util.*;
class testjdbc { public static void main(String arg[]) { try { Class.forName("oracle.jdbc.driver.OracleDriver"); Connection c = DriverManager.getConnection("jdbc:oracle:thin:@10.1.61.197:1521:ora8","scott","tiger"); Statement s = c.createStatement(); ResultSet r = s.executeQuery("select * from dual"); while(r.next()) { System.out.println(r.getString(1)); } }catch(Exception e) { System.out.println(e.toString()); } }}
jdbc连接正常。