当前位置: 技术问答>java相关
我要疯了!为什么在java中可以连上oracle,在jsp中就不行?请看代码:
来源: 互联网 发布时间:2015-01-14
本文导语: 请求test.jsp页的错误信息: Fri Mar 23 08:46:57 CST 2001 driver initialized! java.sql.SQLException: [Microsoft][ODBC ???????ò ???í?÷] ?????????????????????????¨???????????ò at java.lang.Throwable.(Compiled Code) at java.sql.SQLException.(Compiled Code) ...
请求test.jsp页的错误信息:
Fri Mar 23 08:46:57 CST 2001
driver initialized!
java.sql.SQLException: [Microsoft][ODBC ???????ò ???í?÷] ?????????????????????????¨???????????ò at java.lang.Throwable.(Compiled Code) at java.sql.SQLException.(Compiled Code) at sun.jdbc.odbc.JdbcOdbc.createSQLException(Compiled Code) at sun.jdbc.odbc.JdbcOdbc.standardError(Compiled Code) at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Compiled Code) at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Compiled Code) at sun.jdbc.odbc.JdbcOdbcDriver.connect(Compiled Code) at java.sql.DriverManager.getConnection(Compiled Code) at java.sql.DriverManager.getConnection(Compiled Code) at pagecompile._test._test_xjsp.doGet(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled Code) at com.sun.server.http.pagecompile.JSPState.service(Compiled Code) at com.sun.server.http.pagecompile.PageCompileServlet.doService(Compiled Code) at com.sun.server.http.pagecompile.PageCompileServlet.doGet(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled Code) at com.sun.server.ServletState.callService(Compiled Code) at com.sun.server.ServletManager.callServletService(Compiled Code) at com.ibm.servlet.engine.SEServletManager.callServletService(Compiled Code) at com.sun.server.ProcessingState.invokeTargetServlet(Compiled Code) at com.sun.server.http.HttpProcessingState.execute(Compiled Code) at com.sun.server.http.stages.Runner.process(Compiled Code) at com.sun.server.ProcessingSupport.process(Compiled Code) at com.sun.server.Service.process(Compiled Code) at com.ibm.servlet.engine.SEEngine.service(Compiled Code) at com.ibm.servlet.engine.api.ServerEntry.service(Compiled Code) at com.ibm.servlet.engine.nativeEntry.NativeServerEntry.service(Compiled Code) at com.ibm.servlet.engine.outofproc.OutOfProcThread.run(Compiled Code)
test.jsp代码:
配置:
Domino R5 + websphere 2.0
系统classpath:
D:JDK1.1.6libtools.jar;D:JDK1.1.6libdt.jar;D:OracleOra81jdbclibclasses111.zip;D:OracleOra81orbclassesyoj.jar;D:OracleOra81orbclassesshare.zip;d:testt;
websphere classpath:
java.classpath=D:JDK11~1.6libclasses.zip;D:JDK1.1.6libtools.jar;D:JDK1.1.6libdt.jar;D:OracleOra81jdbclibclasses111.zip;D:OracleOra81orbclassesyoj.jar;D:OracleOra81orbclassesshare.zip;d:testt;D:WEBSPH~1APPSER~1classes;D:WEBSPH~1APPSER~1webclasses;D:LotusDominonotes.jar;
这与设置有无关系?而且错误信息为什么是???呢?我将系统的classpath拷到websphere的classpath中,还是一样。有无高手指点一下,非常感谢!!!
Fri Mar 23 08:46:57 CST 2001
driver initialized!
java.sql.SQLException: [Microsoft][ODBC ???????ò ???í?÷] ?????????????????????????¨???????????ò at java.lang.Throwable.(Compiled Code) at java.sql.SQLException.(Compiled Code) at sun.jdbc.odbc.JdbcOdbc.createSQLException(Compiled Code) at sun.jdbc.odbc.JdbcOdbc.standardError(Compiled Code) at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Compiled Code) at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Compiled Code) at sun.jdbc.odbc.JdbcOdbcDriver.connect(Compiled Code) at java.sql.DriverManager.getConnection(Compiled Code) at java.sql.DriverManager.getConnection(Compiled Code) at pagecompile._test._test_xjsp.doGet(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled Code) at com.sun.server.http.pagecompile.JSPState.service(Compiled Code) at com.sun.server.http.pagecompile.PageCompileServlet.doService(Compiled Code) at com.sun.server.http.pagecompile.PageCompileServlet.doGet(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled Code) at com.sun.server.ServletState.callService(Compiled Code) at com.sun.server.ServletManager.callServletService(Compiled Code) at com.ibm.servlet.engine.SEServletManager.callServletService(Compiled Code) at com.sun.server.ProcessingState.invokeTargetServlet(Compiled Code) at com.sun.server.http.HttpProcessingState.execute(Compiled Code) at com.sun.server.http.stages.Runner.process(Compiled Code) at com.sun.server.ProcessingSupport.process(Compiled Code) at com.sun.server.Service.process(Compiled Code) at com.ibm.servlet.engine.SEEngine.service(Compiled Code) at com.ibm.servlet.engine.api.ServerEntry.service(Compiled Code) at com.ibm.servlet.engine.nativeEntry.NativeServerEntry.service(Compiled Code) at com.ibm.servlet.engine.outofproc.OutOfProcThread.run(Compiled Code)
test.jsp代码:
配置:
Domino R5 + websphere 2.0
系统classpath:
D:JDK1.1.6libtools.jar;D:JDK1.1.6libdt.jar;D:OracleOra81jdbclibclasses111.zip;D:OracleOra81orbclassesyoj.jar;D:OracleOra81orbclassesshare.zip;d:testt;
websphere classpath:
java.classpath=D:JDK11~1.6libclasses.zip;D:JDK1.1.6libtools.jar;D:JDK1.1.6libdt.jar;D:OracleOra81jdbclibclasses111.zip;D:OracleOra81orbclassesyoj.jar;D:OracleOra81orbclassesshare.zip;d:testt;D:WEBSPH~1APPSER~1classes;D:WEBSPH~1APPSER~1webclasses;D:LotusDominonotes.jar;
这与设置有无关系?而且错误信息为什么是???呢?我将系统的classpath拷到websphere的classpath中,还是一样。有无高手指点一下,非常感谢!!!
|
为什么不用oracle jdbc driver
|
首先你可以使用搜索功能查找相关帖子,关键字:"oracle"有不少帖子看有没有用处。
其次实在不行,改用javabean连接数据库,再用jsp或servlet调用返回的结果即可。
看看:
http://www.csdn.net/expert/TopicView1.asp?id=76801等等。
其次实在不行,改用javabean连接数据库,再用jsp或servlet调用返回的结果即可。
看看:
http://www.csdn.net/expert/TopicView1.asp?id=76801等等。
|
试一试我这个
这是一个Application 你只要取其中的代码就可以
package jdbc_test;
import javax.swing.UIManager;
import java.awt.*;
import java.sql.*;
public class Application2 {
public Connection con;
public Statement stmt;
public ResultSet rs;
/**Construct the application*/
public Application2() {
}
/**Main method*/
public static void main(String[] args) {
Application2 aa=new Application2();
aa.connection();
aa.getValue();
}
public void connection()
{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.144:1521:csd", "document", "document");
stmt=con.createStatement();
}catch(ClassNotFoundException e1){}
catch(SQLException e2){}
}
public void getValue()
{
try{
rs=stmt.executeQuery("select * from personnel");
while(rs.next())
{
System.out.println(rs.getString(2));
}
}catch(SQLException e3){}
}
}
这是一个Application 你只要取其中的代码就可以
package jdbc_test;
import javax.swing.UIManager;
import java.awt.*;
import java.sql.*;
public class Application2 {
public Connection con;
public Statement stmt;
public ResultSet rs;
/**Construct the application*/
public Application2() {
}
/**Main method*/
public static void main(String[] args) {
Application2 aa=new Application2();
aa.connection();
aa.getValue();
}
public void connection()
{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.144:1521:csd", "document", "document");
stmt=con.createStatement();
}catch(ClassNotFoundException e1){}
catch(SQLException e2){}
}
public void getValue()
{
try{
rs=stmt.executeQuery("select * from personnel");
while(rs.next())
{
System.out.println(rs.getString(2));
}
}catch(SQLException e3){}
}
}
|
我把碰到的怪事情说一下:
java文件是这样的,可以连上:
import java.sql.*;
public class abc {
public static void main(String args[]) {
Connection Conn = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.1:1521:ora1","system","manager");
}
catch (Exception E) {
System.out.println("Connection failed : " + E.getMessage());
}
try {
Statement stmt = Conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from userlist");
rs.next();
String tmp=rs.getString(2);
System.out.println(tmp);
}
catch (SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
}
}
而jsp文件如下:
我在jsp里连接数据库的部份加上try catch就出出问题,真是怪事
java文件是这样的,可以连上:
import java.sql.*;
public class abc {
public static void main(String args[]) {
Connection Conn = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.1:1521:ora1","system","manager");
}
catch (Exception E) {
System.out.println("Connection failed : " + E.getMessage());
}
try {
Statement stmt = Conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from userlist");
rs.next();
String tmp=rs.getString(2);
System.out.println(tmp);
}
catch (SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
}
}
而jsp文件如下:
我在jsp里连接数据库的部份加上try catch就出出问题,真是怪事
|
bug?关注