当前位置: 技术问答>java相关
jsp用JDBC连接数据库Oracle的问题??困惑好久了
来源: 互联网 发布时间:2015-10-04
本文导语: 我现在使用Jdbc:odbc桥接来连Oracle数据库的,很正常。但当我把连接该成JDBC连接时,保错javax.servlet.ServletException: oracle.jdbc.driver.OracleDriver 或是No Suitable Driver。我已经把驱动classes111,classes12都放到WEB-INF/lib下,并在环境...
我现在使用Jdbc:odbc桥接来连Oracle数据库的,很正常。但当我把连接该成JDBC连接时,保错javax.servlet.ServletException: oracle.jdbc.driver.OracleDriver
或是No Suitable Driver。我已经把驱动classes111,classes12都放到WEB-INF/lib下,并在环境变量中加入了classpath f:tomcatwebappsdongxueweb-inflib。请问还要怎么做?火印该怎么做?
这是我的连接数据库的代码
public class db{
String sDBDriver = "oracle.jdbc.driver.OracleDriver";
String sConnStr = "jdbc:oracle:thin:@kkf:1521:mydb";
//String sConnStr = "jdbc:odbc:OracleTest";
//String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
private String username = "kkf";
private String password = "kkfgi";
Connection conn=null;
ResultSet rs=null;
private int concurType = ResultSet.CONCUR_READ_ONLY;
private int scrollType = ResultSet.TYPE_FORWARD_ONLY;
// private int scrollType = ResultSet.TYPE_SCROLL_INSENSITIVE;
public db(){
try{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e){
System.err.println("db():"+e.getMessage());
}
}//faq
public ResultSet executeQuery(String sql){
rs = null;
try{
conn=DriverManager.getConnection(sConnStr,username,password);
Statement stmt=conn.createStatement(scrollType,concurType);
rs=stmt.executeQuery(sql);
}
catch(SQLException ex){
System.err.println("db executeQuery:"+ex.getMessage());
}
return rs;
}//eQ
}//end
或是No Suitable Driver。我已经把驱动classes111,classes12都放到WEB-INF/lib下,并在环境变量中加入了classpath f:tomcatwebappsdongxueweb-inflib。请问还要怎么做?火印该怎么做?
这是我的连接数据库的代码
public class db{
String sDBDriver = "oracle.jdbc.driver.OracleDriver";
String sConnStr = "jdbc:oracle:thin:@kkf:1521:mydb";
//String sConnStr = "jdbc:odbc:OracleTest";
//String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
private String username = "kkf";
private String password = "kkfgi";
Connection conn=null;
ResultSet rs=null;
private int concurType = ResultSet.CONCUR_READ_ONLY;
private int scrollType = ResultSet.TYPE_FORWARD_ONLY;
// private int scrollType = ResultSet.TYPE_SCROLL_INSENSITIVE;
public db(){
try{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e){
System.err.println("db():"+e.getMessage());
}
}//faq
public ResultSet executeQuery(String sql){
rs = null;
try{
conn=DriverManager.getConnection(sConnStr,username,password);
Statement stmt=conn.createStatement(scrollType,concurType);
rs=stmt.executeQuery(sql);
}
catch(SQLException ex){
System.err.println("db executeQuery:"+ex.getMessage());
}
return rs;
}//eQ
}//end
|
try:
set classpath=f:tomcatwebappsdongxueweb-inflibclasses12.zip
or
将classes12.zip解压成后有两个目录javax和oracle,
将这个目录copy到f:tomcatwebappsdongxueweb-infclasses中
http://expert.csdn.net/Expert/topic/670/670716.xml?temp=.9481317
set classpath=f:tomcatwebappsdongxueweb-inflibclasses12.zip
or
将classes12.zip解压成后有两个目录javax和oracle,
将这个目录copy到f:tomcatwebappsdongxueweb-infclasses中
http://expert.csdn.net/Expert/topic/670/670716.xml?temp=.9481317
|
你在环境变量中也要加入classes111,classes12