数据库问题????
我写了个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
请高手指点,如何调试??
万分感谢:)