当前位置: 技术问答>java相关
在jsp中做页面登录,出现错误信息“数据库执行错误:No suitable driver”,我怀疑是不是我不能用sql 7.0
来源: 互联网 发布时间:2015-03-16
本文导语: | import java.sql.*; public class sql_data { String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver"; String sConnStr = "jdbc:odbc:wj"; Connection conn = null; public sql_data() { try { Class.forName(sDBDriver); } catch(java.lang.ClassNotFoundException e...
|
import java.sql.*;
public class sql_data
{
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:wj";
Connection conn = null;
public sql_data()
{
try
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e)
{
System.err.println("sql_data(): " + e.getMessage());
}
}
public void executeInsert(String sql)
{
try
{
conn = DriverManager.getConnection(sConnStr);
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.err.println("sql_data.executeUpdate:"+ex.getMessage());
}
}
}
试试这段代码!!
public class sql_data
{
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:wj";
Connection conn = null;
public sql_data()
{
try
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e)
{
System.err.println("sql_data(): " + e.getMessage());
}
}
public void executeInsert(String sql)
{
try
{
conn = DriverManager.getConnection(sConnStr);
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.err.println("sql_data.executeUpdate:"+ex.getMessage());
}
}
}
试试这段代码!!