java 连接oracle 出错
我用JAVA远程连接ORACLE 8I 时出现异常,下面是连接代码和出错报告请高手帮忙看看。
public static Connection dbConn(String name,String pass) {
try {
Class.forName( "oracle.jdbc.OracleDriver ");
} catch (
ClassNotFoundException e) {
e.printStackTrace();
}
try {
conn =DriverManager.getConnection( "jdbc:oracle:thin:@10.53.23.11:1521:xMFY ",name,pass);
} catch (
SQLException e1) {
e1.printStackTrace();
}
return conn;
}
public static void main(String[] args){
try{
conn=dbConn( "btsrmis ", "btsrmis ");
if(conn==null){
System.out.println( "ORACLE DB connect failed! ");
System.exit(0);
}
System.out.println( "ORACLE DB connect success! ");
conn.close();
}catch(Exception e){
e.printStackTrace();
}
}
ORACLE驱动CLASSES12.JAR都装好了。运行出错:
java.sql.SQLException: Io 异常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=135294976)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:323)
at oracle.jdbc.driver.OracleConnection. <init> (OracleConnection.java:263)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at db.oracle.util.DBConn.dbConn(DBConn.java:16)ORACLE DB connect failed!
at db.oracle.util.DBConn.main(DBConn.java:25)
会不会是远程数据库问题?
------解决方案--------------------oracle是不是已经运行?
不知道 "jdbc:oracle:thin:@10.53.23.11:1521:xMFY "是不是正确的
其它地方没有错误
下面异常出现在执行conn =DriverManager.getConnection( "jdbc:oracle:thin:@10.53.23.11:1521:xMFY ",name,pass);的时候
java.sql.SQLException: Io 异常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=135294976)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
------解决方案--------------------网上看到的一篇帖子希望对楼主有帮助:
关于ORACLE的ora-12505报错以及连接问题的问答资料
1:配置JDBC Connection Pool时出错
原文:http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=123&threadID=8769
问题描述:我安装weblogic8.1后,准备连接oracle9i,创建JDBC Connection Pool时出错,错误提示:
Io 异常:
Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153093120)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
Driver Classname: oracle.jdbc.driver.OracleDriver
URL:jdbc:oracle:thin:@145.32.16.1:1521:zzlt
oracle的日志:
TNS-12505: TNS:listener could not resolve SID given in connect descriptor
sql plus使用都很正常。
------------------
解答1:我也遇到这个问题,