Topic: java连接oracle的问题 请教 |
Print this page |
1.java连接oracle的问题 请教 | Copy to clipboard |
Posted by: Jsharp Posted on: 2006-12-05 15:34 这段代码在学校的机器可以连上oracle 但回到家中便不行了 package com.test; import java.sql.*; public class ConnectBean { private String username="system"; private String password="manager"; private String url="jdbc:oracle:thin:@localhost:1521:MYDATA"; private String driver="oracle.jdbc.driver.OracleDriver"; public ConnectBean() { } public Connection getConnection(){ Connection conn = null; try { Class.forName(driver); try { conn = DriverManager.getConnection(url, username, password); } catch (SQLException ex1) { } } catch (ClassNotFoundException ex) { } return conn; } public static void main(String[] args) { ConnectBean conBean = new ConnectBean(); Connection conn = conBean.getConnection(); if(conn!=null){ System.out.println("conn ok"); }else{ System.out.println("conn error"); } } } 总是conn error 服务打开了,端口号是1521 请问是什么原因的 学校的机器是 win2k 我家的是xp home 装的是oracle 9i 驱动是oracle里面自己带的 classes12.jar 谢谢 |
2.Re:java连接oracle的问题 请教 [Re: Jsharp] | Copy to clipboard |
Posted by: 九佰 Posted on: 2006-12-05 19:46 提示什么错误? 你的Oracle9i安装的都一样吗? |
3.Re:java连接oracle的问题 请教 [Re: Jsharp] | Copy to clipboard |
Posted by: Jsharp Posted on: 2006-12-05 21:15 谢谢九佰! 没有提示任何错误 打印我的那句 System.out.println("conn error"); 根本就没有取得连接 我打印了一下catch的内容 如下: java.sql.SQLException: Io 异常: Connection refused(DESCRIPTION=(ERR=12518)(VSNNUM=150999297)(ERROR_STACK=(ERROR=(CODE=12518)(EMFI=4))(ERROR=(CODE=12560)(EMFI=4)))) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:335) at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:361) at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:442) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:321) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:171) at com.test.ConnectBean.getConnection(ConnectBean.java:16) at com.test.ConnectBean.main(ConnectBean.java:31) 我不知道我家和学校是否安装的是一样的 家中的oracle自己用起来很正常 |
4.Re:java连接oracle的问题 请教 [Re: Jsharp] | Copy to clipboard |
Posted by: Jsharp Posted on: 2006-12-05 22:06 问题已解决 在oracle的监听器上加 DIRECT_HANDOFF_TTC_LISTENER = OFF 这么一句话就OK了 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |