免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4867 | 回复: 4
打印 上一主题 下一主题

JSP:The Network Adapter could not establish the connection [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-02-14 10:02 |只看该作者 |倒序浏览
我的数据库是ORACLE8。17,装在SCOUNIX上,在WINDOWS+TOMCAT下用JSP连数据库,报错:The Network Adapter could not establish the connection,可是我用同样的代码连另一台WINDWOS下的ORACLE8。17,只改了个IP和服务名,一点问题都没有,SCOUNIX里的数据库没有问题,我用PB8可以连上去,SQLPLUS 也可以。请高手指教

论坛徽章:
0
2 [报告]
发表于 2004-02-14 10:35 |只看该作者

JSP:The Network Adapter could not establish the connection

几个可能的方法
1.检查你的scounix上的oracle listener的状态

  1. lsnrctl status
  2. lsnrctl stop
  3. lsnrctl start
复制代码

2.换成下面的connection url

  1. jdbc:oracle:thin:username/password@(description=(address_list=(address=(protocol=tcp)(host=xxx.xxx.xxx.xxx)(port=1521)))(source_route=yes)(connect_data=(sid=ansid)))
复制代码

论坛徽章:
0
3 [报告]
发表于 2004-02-14 10:57 |只看该作者

JSP:The Network Adapter could not establish the connection

运行
lsnrctl stop
lsnrctl start
后可以提取数据
可提取一次后有不行
重新运行上述命令后有可以

论坛徽章:
0
4 [报告]
发表于 2004-02-14 11:03 |只看该作者

JSP:The Network Adapter could not establish the connection

String sDBDriver = "oracle.jdbc.driver.OracleDriver";
String user="bgfa";
String pwd="bgfa";
String sConnStr="jdbcracle:thin210.35.248.162:1521racledb";
//数据库连接对象
  Connection conn = null;
  //语句对象
  ResultSet Rs = null;
  public ConnDatabase() {
    try { //登记jdbc驱动程序
      Class.forName(sDBDriver);
    }
    catch (ClassNotFoundException e) {
      System.err.println(e.getMessage());
    }
  }
  public ResultSet executeQuery(String sql) { //查询
    try { //连接数据库
      conn = DriverManager.getConnection(sConnStr, user, pwd);
      //创建语句对象
      Statement stmt = conn.createStatement();
      Rs = stmt.executeQuery(sql);

    }
    catch (SQLException ex) {

      System.err.println(ex.getMessage());
    }

    return Rs;
  }

论坛徽章:
0
5 [报告]
发表于 2004-02-14 13:08 |只看该作者

JSP:The Network Adapter could not establish the connection


  1. ......
  2. String sDBDriver = "oracle.jdbc.driver.OracleDriver";
  3. //String user="bgfa";
  4. //String pwd="bgfa";
  5. String sConnStr="jdbc:oracle:thin:bgfa/bgfa@(description=(address_list=(address=(protocol=tcp)(host=210.35.248.162)(port=1521)))(source_route=yes)(connect_data=(sid=oracledb))) ";
  6. ......
  7. conn = DriverManager.getConnection(sConnStr);
  8. ......
复制代码


修改你的tomcat所在的windows主机的hosts文件,加入数据库所在的服务器的ip和主机名,如果是win2000的话,该文件在%WINDIR%\system32\drivers\etc目录下
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP