日期:2014-05-20  浏览次数:20802 次

为什么我的JSP连接Oracle总报IO错误?
测试程序是:
  <sql:setDataSource driver="oracle.jdbc.OracleDriver"
  url="jdbc:oracle:thin:@localhost:1521:wcd"
  user="system" password="manager" var="conn"/>
  <sql:query var="aaa" dataSource="${conn}">
  select * from users
  </sql:query>
  <c:forEach var="u" items="${aaa.rows}">
  <c:out value="${u}" />
  </c:forEach>


错误是:javax.servlet.ServletException: Unable to get connection, DataSource invalid: "java.sql.SQLException: Io 异常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))"
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.test_jsp._jspService(test_jsp.java:92)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

请各位帮帮忙啊?

------解决方案--------------------
数据源无效,拒绝连接。你看看用户名密码对不对,还有就是数据库名字似乎不是这样写的。
------解决方案--------------------
很明显,通过上面的exception来看,在jsp里面就不能这样写,大家都知道,JSP是预编译成servlet来运行的,先去找一下,JSP被编译成的servlet去看一下!

{
javax.servlet.ServletException:
javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 
} 从这里就可以看出来是servlet的异常,去改个java类试一下!