HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: Io 异常: The Network Adapter could not establish the connection
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:845)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:778)
org.apache.jsp.bbs.testoracle_jsp._jspService(testoracle_jsp.java:80)
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)
root cause java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java)
oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java)
oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java)
java.sql.DriverManager.getConnection(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.bbs.testoracle_jsp._jspService(testoracle_jsp.java:52)
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)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.29 logs.

解决方案 »

  1.   

    <%@ page contentType="text/html;charset=gb2312"%>   
    <%@ page import="java.sql.*"%> 
    <html>   
    <body>   
    <%Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();   
    String url="jdbc:oracle:thin:@localhost:1521:dbname"; 
    //orcl为你的数据库的SID 
    String user="system"; 
    String password="y111111"; 
    Connection conn= DriverManager.getConnection(url,user,password);   
    Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);   
    String sql="select * from testoracle";   
    ResultSet rs=stmt.executeQuery(sql);   
    while(rs.next()) {%>   
    您的第一个字段内容为:<%=rs.getString(1)%>   
    您的第二个字段内容为:<%=rs.getString(2)%>   
    <%}%>   
    <%out.print("数据库操作成功,恭喜你");%>   
    <%rs.close();   
    stmt.close();   
    conn.close();   
    %>   
    </body>   
    </html>