当前位置: 技术问答>java相关
为什么说我没有匹配的驱动程序哪?(内附源代码)
来源: 互联网 发布时间:2015-02-11
本文导语: 使用dat.executeQuery() 时提示 没有匹配的 driver import java.sql.*; public class dat { String sdbdriver="sun.jdbc.odbc.JdbcOdbcDriver"; String sconnstr="jdbc:odbc:faq"; Connection conn=null; ResultSet rs=null; public void executeInsert(String...
使用dat.executeQuery() 时提示 没有匹配的 driver
import java.sql.*;
public class dat
{
String sdbdriver="sun.jdbc.odbc.JdbcOdbcDriver";
String sconnstr="jdbc:odbc:faq";
Connection conn=null;
ResultSet rs=null;
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.exeuteUpdate:"+ex.getMessage());
}
}
public ResultSet executeQuery(String sql)
{
rs=null;
try
{
conn=DriverManager.getConnection(sconnstr);
Statement stmt=conn.createStatement();
System.out.println(sql);
stmt.executeQuery(sql);
}
catch (SQLException ex)
{
System.err.println("sql_data.executeUpdate:"+ex.getMessage());
}
return rs;
}
public void executeDelete(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());
}
}
}
import java.sql.*;
public class dat
{
String sdbdriver="sun.jdbc.odbc.JdbcOdbcDriver";
String sconnstr="jdbc:odbc:faq";
Connection conn=null;
ResultSet rs=null;
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.exeuteUpdate:"+ex.getMessage());
}
}
public ResultSet executeQuery(String sql)
{
rs=null;
try
{
conn=DriverManager.getConnection(sconnstr);
Statement stmt=conn.createStatement();
System.out.println(sql);
stmt.executeQuery(sql);
}
catch (SQLException ex)
{
System.err.println("sql_data.executeUpdate:"+ex.getMessage());
}
return rs;
}
public void executeDelete(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());
}
}
}
|
换个1.2以上的JDK 它自带了sun.jdbc.odbc包
|
请问:
sun.jdbc.odbc在什么位置(物理位置,d:jdk1.3?)
sun.jdbc.odbc在什么位置(物理位置,d:jdk1.3?)
|
加一条语句:
import sun.jdbc.odbc.*;
import sun.jdbc.odbc.*;
|
user Vage or Jbuild