jsp连接ORACLE提示错误信息
<%@pagelanguage="java"import="java.io.*,java.sql.*,javax.sql.*,javax.naming.*"%><%@pa...
<%@ page language="java" import="java.io.*,java.sql.*,javax.sql.* ,javax.naming.*"%>
<%@ page contentType="text/html;charset=gb2312" %>
<HTML>
<HEAD>
<TITLE>测试连接</TITLE>
</HEAD>
<font size=4>
<%
//数据库驱动名
String driverName="oracle.jdbc.driver.OracleDriver";
//数据库用户名
String userName="bill";
//密码
String userPasswd="bill";
//数据库名
String dbName="bill";
//连接字符串
String url="jdbc:oracle:thin:@localhost:1521:bill";
//结果
ResultSet rs = null;
try{
Class.forName(driverName);
Connection conn=DriverManager.getConnection(url,userName,userPasswd);
Statement stmt = conn.createStatement();
rs = stmt.executeQuery("select * from qq_jdbc_test");
while (rs.next())
{
out.println("" + rs.getInt(1) + "");
out.println(":"+"<br>");
}
rs.close();
}
catch(Exception e)
{out.println(e);
}
%>
</BODY>
</HTML>
====
打开地址:http://localhost:8080/driver.jsp
报错:java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
===是不是我什么环境没有打好?请各位大侠看下~谢谢~ 展开
<%@ page contentType="text/html;charset=gb2312" %>
<HTML>
<HEAD>
<TITLE>测试连接</TITLE>
</HEAD>
<font size=4>
<%
//数据库驱动名
String driverName="oracle.jdbc.driver.OracleDriver";
//数据库用户名
String userName="bill";
//密码
String userPasswd="bill";
//数据库名
String dbName="bill";
//连接字符串
String url="jdbc:oracle:thin:@localhost:1521:bill";
//结果
ResultSet rs = null;
try{
Class.forName(driverName);
Connection conn=DriverManager.getConnection(url,userName,userPasswd);
Statement stmt = conn.createStatement();
rs = stmt.executeQuery("select * from qq_jdbc_test");
while (rs.next())
{
out.println("" + rs.getInt(1) + "");
out.println(":"+"<br>");
}
rs.close();
}
catch(Exception e)
{out.println(e);
}
%>
</BODY>
</HTML>
====
打开地址:http://localhost:8080/driver.jsp
报错:java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
===是不是我什么环境没有打好?请各位大侠看下~谢谢~ 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询