解决Linux下JSP连接Orcale的著名错误Java.SQL.Exception The Network Adapter could not establish the connection .
来源:互联网 发布:ubuntu server精简 编辑:程序博客网 时间:2024/05/22 09:48
本来一个context在A主机(Windows+Tomcat5.0.28) 能够通过JDBC正常连接C主机(Windows+Orcale),后来移植到B主机(Linux+Tomcat5.0.28),访问带有数据库连接的页面,出现著名的:
javax.servlet.ServletException: Io /x{5F02}/x{5E38}: The Network Adapter could not establish the connection
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.test_jsp._jspService(test_jsp.java:66)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:79)
到www.baidu.com一搜,有很多人遇到类似的错误,网上别人的解答也大都集中在一下几个方面:
1. Orcale服务是否正常,TNS是否启动;
2. 将URL里面的主机名改为IP,端口是否正确,用户名、密码是否正确;
3. 因为是Linux,防火墙是否拦截了JDBC连接请求;
由于我是将整个context从windows上拷贝至Linux下,因此在windows下可以连接的配置(URL的写法)可以确定正确,而且Oracle服务器肯定正常(否则,从A主机无法访问),因此错误原因1,2可以基本排除。后来我用iptables -F将防火墙关闭,仍然出现上述错误,后来还是到SUN的技术论坛:http://forum.java.sun.com/thread.jspa?forumID=48&threadID=284032上找到了答案:
1) Check for the class path frst.
2) Check whether the listner is running.
Linux or Solaris check --> ORA_HOME/bin/lsnrctrl.sh
Windows -->ORA_HOME/bin/lsnrctrl.exe
3) If these are Okay, the problem is with your Connection URL. Check the following.
In case of Linux or Solaris Use the below code:
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=Host_name)(PORT=1521)))(CONNECT_DATA=(SID=service_name)(SERVER=DEDICATED)))", "usernam", "password");
In the above URL SERVER = DEDICATED is mandatory for Linux or Solaris.
In case of WINDOWS Use the below code:
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host_name)(PORT=1521)))(CONNECT_DATA=(SID=service_name)(SERVER=DEDICATED)))", "username", "password");
In the above URL (SERVER = DEDICATED) is optional for Windows.
写的很清楚,URL 中的(SERVER = DEDICATED)对Linux是必须的,对windows是可选的。至此,卡壳了2天的问题终于解决了,长舒一口气,没有妨碍项目进度。不过,由于最近项目很忙,没有细致研究其中的原因,或者还有别的什么解决办法,以后再说吧!
得到一个结论:遇到问题要自己善于利用网络解决,最好到国外的一些官方网站逛逛!
- 解决Linux下JSP连接Orcale的著名错误Java.SQL.Exception The Network Adapter could not establish the connection .
- Java.Sql.Sqlexception: Io Exception: The Network Adapter Could Not Establish The Connection
- 异常java.sql.SQLException: Io exception:The Network Adapter could not establish connection
- sql developer连接数据库时出现的The Network Adapter could not establish the connection解决办法
- 数据库连接错误The Network Adapter could not establish the connection
- 错误The Network Adapter could not establish the connection
- 数据库连接错误The Network Adapter could not establish the connection
- 数据库连接错误The Network Adapter could not establish the connection
- IO 错误: The Network Adapter could not establish the connection
- 解决The Network Adapter could not establish the connection
- The Network Adapter could not establish the connection解决
- 解决:Oracle the network adapter could not establish the connection
- the network adapter could not establish the connection的解决方法
- Io exception: The Network Adapter could not establish the connection异常的解决办法
- 连接数据库错误The Network Adapter could not establish the connection
- jdbc连接错误 SQLException: The Network Adapter could not establish the connection
- Orcale I/O例外: The Network Adapter could not establish the connection
- 使用Oracle连接池错误 Cannot create PoolableConnectionFactory(Io 异常: The Network Adapter could not establish the connection )的解决方法
- 对话框FAQ(来自网络)
- MSDN的文档 Open 方法 (ADO Recordset)
- How To Print Concurrent Requests in PDF Format
- 网络数据包监视程序开发(十四)---毕设结束了
- [ASP.NET学习笔记之四]数据集的使用方法和技巧
- 解决Linux下JSP连接Orcale的著名错误Java.SQL.Exception The Network Adapter could not establish the connection .
- 在weblogic上发布hiberante
- 报表式CListCtrl的使用详解初稿
- SOAPtest
- 欺骗的艺术(第二章 无害信息的价值六)
- 人民币转化
- PHP4 DAO 类
- CSS学习笔记四
- 一个项目经理的个人体会:最忌讳的就是完美主义倾向