jsp连接oracle9i的问题
1.我的tomcat5.0安装在D盘,在E盘建立了一个应用e:\testoracle里面有一个JSP的连接页面
2.在testoracle有个WEB-INF的文件夹,里面有lib\classes.jar
3.在D:\Tomcat\conf的server.xml配置了应用的路径
<Context path= "/a " docBase= "E:\testoracle " debug= "0 "/>
我只开了ORACLE的一个服务OracleServiceORACLE90,可以不?
我用的是ADSL的动态IP上网
index.jsp
*****************************************
<%@page contentType= "text/html;charset=gb2312 "%>
<%@page language= "java " import= "java.sql.* "%>
<html>
<body>
<%
Class.forName( "oracle.jdbc.driver.OracleDriver ").newInstance();
String url= "jdbc:oracle:thin:@localhost:1521:ORACLE90 ";
String user= "scott ";
String password= "tiger ";
Connection conn=DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql= "select * from person ";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
%> 你的第一个字段内容为: <%=rs.getString(1)%>
你的第二个字段内容为: <%=rs.getString(2)%>
<%
}
out.print( "数据库操作成功,恭喜你! ");
rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
**************************************
出错信息:
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
请问大家是那里出错了?还需要配置那些地方才可以啊?
JDK1.5的CLASSPATH是C:\Program Files\Java\j2sdk1.5.0\lib\tools.jar;C:\Program Files\Java\j2sdk1.5.0\lib\dt.jar;
------解决方案--------------------The Network Adapter could not establish the connection 把这个放到百度搜索下,你可以找到5000多的页面
------解决方案--------------------oralce的jar包加到classpath了吗?
Class.forName( "oracle.jdbc.driver.OracleDriver ").newInstance(); 改为:
Class.forName( "oracle.jdbc.driver.OracleDriver "); (先试试)
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 改为:
Statement stmt=conn.createStatement(); (先试试)
------解决方案--------------------与程序无关,可能是监听器没有启动,lz用你的用户名和密码登陆客户端管理工具(具体名称忘了)或者重新设置下oracle网络设置
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.aiyiweb.com/java-web/317.html