捕捉到ClassNotFoundException,SQLException错误
如题,是什么错误啊,我是不是需要在环境变量里加什么jar?
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*" %>
<html><body>
<%
Connection con;
Statement sql;
ResultSet rs;
try
{
Class.forName("tdh.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{
out.print("ClassNotFoundException<br>");
}
try
{
con=DriverManager.getConnection("jdbc:odbc:tdh","sa","");
sql=con.createStatement();
rs=sql.executeQuery("select * from jobs");
out.print("<table border>");
out.print("<tr>");
out.print("<th width=100>"+"description");
out.print("<th width=100>"+"min");
out.print("<th width=100>"+"max");
out.print("</tr>");
while(rs.next())
{
out.print("<tr>");
out.print("<td width=100>"+rs.getString(1)+"</td>");
out.print("<td width=100>"+rs.getString(2)+"</td>");
out.print("<td width=100>"+rs.getString(3)+"</td>");
out.print("</tr>");
}
out.print("</table>");
rs.close();
con.close();
}
catch(SQLException e1)
{
out.print("SQLException<br>");
}
%>
</body></html>
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*" %>
<html><body>
<%
Connection con;
Statement sql;
ResultSet rs;
try
{
Class.forName("tdh.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{
out.print("ClassNotFoundException<br>");
}
try
{
con=DriverManager.getConnection("jdbc:odbc:tdh","sa","");
sql=con.createStatement();
rs=sql.executeQuery("select * from jobs");
out.print("<table border>");
out.print("<tr>");
out.print("<th width=100>"+"description");
out.print("<th width=100>"+"min");
out.print("<th width=100>"+"max");
out.print("</tr>");
while(rs.next())
{
out.print("<tr>");
out.print("<td width=100>"+rs.getString(1)+"</td>");
out.print("<td width=100>"+rs.getString(2)+"</td>");
out.print("<td width=100>"+rs.getString(3)+"</td>");
out.print("</tr>");
}
out.print("</table>");
rs.close();
con.close();
}
catch(SQLException e1)
{
out.print("SQLException<br>");
}
%>
</body></html>
...全文
相关推荐
使用IDEA启动项目遇见ClassNotFoundException的解决方案
错误信息如下:Caused by: java.sql.SQLException: com.mysql.jdbc.Driverat com.alibaba.druid.util.JdbcUtils.createDriver
java.sql.SQLException: com.mysql.jdbc.Driver问题
这个错误通常表示 Java 应用程序无法找到或加载 MySQL 的 JDBC 驱动程序。
SQLException解决办法.md
同时,务必处理所有可能的异常类型,例如ClassNotFoundException,确保所有异常都能得到妥善处理。解决SQLException需要综合运用异常处理、错误诊断、资源管理和错误应对策略。
JDBC 程序的常见错误及调试方法
错误信息通常为java.lang.ClassNotFoundException,提示缺少驱动类,例如在MySQL数据库中,会提示找不到com.mysql.jdbc.Driver类。
java出现404的原因是_关于出现404错误的原因 关于出现500错误的原因
**SQLException**:SQL查询错误,可能是因为SQL语法错误、表名或字段名错误等。4.


Web 开发
