我的代码是这样写的
<%@ page import="java.sql.*"%>
<html>
<body>
<%
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
String user="scott";
String password="tiger";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); String sql="select * from tb_group";
ResultSet rs=stmt.executeQuery(sql);
while (rs.next())
{
out.println(rs.getInt(1));
out.println(rs.getString(2));
}
rs.close();
stmt.close();
conn.close();%>
</body>
</html>
出现如下错误:
exception org.apache.jasper.JasperException: An exception occurred processing JSP page /oracle2.jsp at line 96: String url="jdbc:oracle:thin:@localhost:1521:orcl";
7: String user="scott";
8: String password="tiger";
9: Connection conn= DriverManager.getConnection(url,user,password);
10: Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); String sql="select * from tb_group";
11: ResultSet rs=stmt.executeQuery(sql);
12: while (rs.next())root cause javax.servlet.ServletException: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:orcl请大家帮我看看
<%@ page import="java.sql.*"%>
<html>
<body>
<%
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
String user="scott";
String password="tiger";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); String sql="select * from tb_group";
ResultSet rs=stmt.executeQuery(sql);
while (rs.next())
{
out.println(rs.getInt(1));
out.println(rs.getString(2));
}
rs.close();
stmt.close();
conn.close();%>
</body>
</html>
出现如下错误:
exception org.apache.jasper.JasperException: An exception occurred processing JSP page /oracle2.jsp at line 96: String url="jdbc:oracle:thin:@localhost:1521:orcl";
7: String user="scott";
8: String password="tiger";
9: Connection conn= DriverManager.getConnection(url,user,password);
10: Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); String sql="select * from tb_group";
11: ResultSet rs=stmt.executeQuery(sql);
12: while (rs.next())root cause javax.servlet.ServletException: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:orcl请大家帮我看看
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货