请教:No suitable driver

stw2662 2003-03-21 08:35:03
我的tomcat 抛出:No suitable driver
数据源我建好了 jdk 的环境设置也没问题 源文件如下 :faq.java
package test;
import java.sql.*;
public class faq {
String sDBDriver ="sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr ="jdbc:odbc:faq";
Connection conn=null;
ResultSet rs =null;
public faq() {
try {
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e)
{System.err.println("faq():" +e.getMessage());
}
}

public ResultSet executeQuery(String sql)
{
rs=null;
try{
conn=DriverManager.getConnection(sConnStr);
Statement stmt =conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException e){
System.err.println("sql.executeQuery():" + e.getMessage());
}
return rs;
}

}

faq.jsp
<html>
<head>
<meta http-equiv="Content Type" content="text/html;charset=gb2312">
<title>我的faq</title>
</head>
<body>
<p><b>这是我的FAQ</b></p>
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="work" scope="page" class="test.faq"/>
<%
ResultSet RS = work.executeQuery("SELECT * FROM faqs");
String tt;

while(RS.next())
{
tt=RS.getString("answers");
out.println("<LI>" + RS.getString("subject")+"</LI>");
out.println("<pre>" + tt + "</pre>");
}

RS.close();
%>
</body>
</html>

帮帮我,搜了很多帖子 没有解决问题,驱动程序要其他的设置吗?
...全文
28 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
icecloud 2003-03-21
  • 打赏
  • 举报
回复
可能是没有建立odbc连接吧?
在控制面板里面,打开odbc,在system dsn里面建立名字为faq的连接
sparkwu 2003-03-21
  • 打赏
  • 举报
回复
Modify:
Hello brother:
Your source no problem.
The problem happen:
you must with ODBC data source Administrator console add a DSN.
=> follow your source String sConnStr ="jdbc:odbc:faq";
called :faq


If any question.
Send short message to me.
sparkwu 2003-03-21
  • 打赏
  • 举报
回复
Hello brother:
Your source no problem.
The problem happen:
you must with ODBC data source Administrator console add a DSN.

If any question.
Send short message to me.

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧