数据库问题????

zwd2878 zwd2878 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我写了个bulletins.properties文件
内容为:
db_driver=oracle.jdbc.driver.OracleDriver
db_url=jdbc:oracle:thin:@192.168.0.11:1521:orcl1
db_user=test
db_password=test

在java文件中,我通过下面方式调用

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;

public class bulletinshttp extends HttpServlet
{
private static Properties http_props = new Properties();
private static String db_Driver;
private static String db_Url;
private static String db_User;
private static String db_Password;


Connection connect;

public void init(ServletConfig configuration)
throws ServletException
{
super.init(configuration);

try
{
// FileInputStream infile = new FileInputStream("/bulletins/bulletins.properties");

InputStream infile = this.getClass().getResourceAsStream("/bulletins.properties");




http_props.load(infile);
db_Driver = http_props.getProperty("db_driver");
db_Url = http_props.getProperty("db_url");
db_User = http_props.getProperty("db_user");
db_Password = http_props.getProperty("db_password");



infile.close();
}
catch (Exception e)
{
System.out.println(e);
}
}

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
doPost(req, resp);
}

public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{


PrintWriter outhtml;

String driver = db_Driver;
String url = db_Url;
String user = db_User;
String password = db_Password;
String urlextrapath;

resp.setContentType("text/html");
outhtml = resp.getWriter();

/*
outhtml.println ("driver = "+driver);
outhtml.println ("url = "+url);
outhtml.println ("user = "+user);
outhtml.println ("password = "+password);
*/

try
{
Class.forName(driver);
connect = DriverManager.getConnection("url", "user", "password");
urlextrapath = req.getPathInfo();
bulletins bltn = new bulletins();
bltn.connect = connect;
Enumeration enum = req.getParameterNames();


…………………………………………………………………………

…………

}
catch(ClassNotFoundException e)
{
outhtml.println ("Cannot load driver:"+ e.getMessage ());
}
catch(SQLException e)
{
outhtml.println ("SQLException: "+e.getMessage ());
}
finally
{
try
{
if(connect!=null)
connect.close ();
}
catch(SQLException ignored)
{}

}
}
}



另外,在tomcat的common/lib里面已经加了class12.jar及class12.zip

可是最后测试时:却捕捉到下面的错误(在html页面上)

SQLException: No suitable driver


请高手指点,如何调试??

万分感谢:)
...全文

相关推荐

评论 14
收藏 已收藏
分享
返回顶部
zwd2878
Web 开发 81,108 成员 341,721 内容