11 个解决方案
#1
看看你怎么用得吧!
#2
up
#3
就是一段jsp代码,直接访问数据库,在tomcat下部署成功,但是部署到weblogic6.1会报上面的错误:
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page info="database handler"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<!--导入结束-->
<html>
<head>
<title>数据库连接实验</title>
</head>
<body>
<%
String sDBDriver = "oracle.jdbc.driver.OracleDriver";
String sConnStr = "jdbc:oracle:thin:@zhh:1521:zhhdb";
Statement Stmt=null;
Connection conn=null;
try
{
String user="qqq";
String password="qqq";
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
conn= DriverManager.getConnection(sConnStr,user,password);
Stmt=conn.createStatement();
/*创建JDBC声明*/
}
catch (Exception e) {out.println("失败");}
out.println("恭喜,表连接创建成功!");
ResultSet rs=Stmt.executeQuery("select * from jcmd");
while(rs.next())
{
out.println(rs.getString("name"));
}
rs.close();
%>
</body>
</html>
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page info="database handler"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<!--导入结束-->
<html>
<head>
<title>数据库连接实验</title>
</head>
<body>
<%
String sDBDriver = "oracle.jdbc.driver.OracleDriver";
String sConnStr = "jdbc:oracle:thin:@zhh:1521:zhhdb";
Statement Stmt=null;
Connection conn=null;
try
{
String user="qqq";
String password="qqq";
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
conn= DriverManager.getConnection(sConnStr,user,password);
Stmt=conn.createStatement();
/*创建JDBC声明*/
}
catch (Exception e) {out.println("失败");}
out.println("恭喜,表连接创建成功!");
ResultSet rs=Stmt.executeQuery("select * from jcmd");
while(rs.next())
{
out.println(rs.getString("name"));
}
rs.close();
%>
</body>
</html>
#4
gz
#5
up
#6
将oracle9i带的那个classes12.jar放到classpath的最前面即可!
#7
试过了,不行啊
我发现问题是在ResultSet rs=Stmt.executeQuery("select * from jcmd");
这句话,因为如果只是连接数据库是成功的,只是取数据的时候失败
我发现问题是在ResultSet rs=Stmt.executeQuery("select * from jcmd");
这句话,因为如果只是连接数据库是成功的,只是取数据的时候失败
#8
很简单的问题,为什么没有人知道!
#9
在startWebLogic.cmd里的set CLASSPATH中将classes12.jar放在最前面就OK
#10
只要放在weblogic.jar前都可以
#11
smilelee(smilelee)说的对,谢谢
#1
看看你怎么用得吧!
#2
up
#3
就是一段jsp代码,直接访问数据库,在tomcat下部署成功,但是部署到weblogic6.1会报上面的错误:
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page info="database handler"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<!--导入结束-->
<html>
<head>
<title>数据库连接实验</title>
</head>
<body>
<%
String sDBDriver = "oracle.jdbc.driver.OracleDriver";
String sConnStr = "jdbc:oracle:thin:@zhh:1521:zhhdb";
Statement Stmt=null;
Connection conn=null;
try
{
String user="qqq";
String password="qqq";
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
conn= DriverManager.getConnection(sConnStr,user,password);
Stmt=conn.createStatement();
/*创建JDBC声明*/
}
catch (Exception e) {out.println("失败");}
out.println("恭喜,表连接创建成功!");
ResultSet rs=Stmt.executeQuery("select * from jcmd");
while(rs.next())
{
out.println(rs.getString("name"));
}
rs.close();
%>
</body>
</html>
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page info="database handler"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<!--导入结束-->
<html>
<head>
<title>数据库连接实验</title>
</head>
<body>
<%
String sDBDriver = "oracle.jdbc.driver.OracleDriver";
String sConnStr = "jdbc:oracle:thin:@zhh:1521:zhhdb";
Statement Stmt=null;
Connection conn=null;
try
{
String user="qqq";
String password="qqq";
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
conn= DriverManager.getConnection(sConnStr,user,password);
Stmt=conn.createStatement();
/*创建JDBC声明*/
}
catch (Exception e) {out.println("失败");}
out.println("恭喜,表连接创建成功!");
ResultSet rs=Stmt.executeQuery("select * from jcmd");
while(rs.next())
{
out.println(rs.getString("name"));
}
rs.close();
%>
</body>
</html>
#4
gz
#5
up
#6
将oracle9i带的那个classes12.jar放到classpath的最前面即可!
#7
试过了,不行啊
我发现问题是在ResultSet rs=Stmt.executeQuery("select * from jcmd");
这句话,因为如果只是连接数据库是成功的,只是取数据的时候失败
我发现问题是在ResultSet rs=Stmt.executeQuery("select * from jcmd");
这句话,因为如果只是连接数据库是成功的,只是取数据的时候失败
#8
很简单的问题,为什么没有人知道!
#9
在startWebLogic.cmd里的set CLASSPATH中将classes12.jar放在最前面就OK
#10
只要放在weblogic.jar前都可以
#11
smilelee(smilelee)说的对,谢谢