java.lang.ClassNotFoundException:sun.jdbc.odbc
public class AccessDbConnection { public static void main(String[] args) { System.out.println("**ACCESS DB CONNECTION**"); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // for MS Access ... MS access driver loading String conURL = "jdbc:odbc:sampleDNS"; Connection con = DriverManager.getConnection(conURL); Statement statement = con.createStatement(); String qry = "SELECT * FROM Table1"; ResultSet rs = statement.executeQuery(qry); while(rs.next()) { String id = rs.getString("ID") ; String fname = rs.getString("First_Name"); String lname = rs.getString("Last_Name"); System.out.println(id + fname + lname); } } catch (ClassNotFoundException ex) { System.out.println("Classforname Exception!!"); Logger.getLogger(AccessDbConnection.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { System.out.println("DriverManager Exception!!"); Logger.getLogger(AccessDbConnection.class.getName()).log(Level.SEVERE, null, ex); } }}
class.forname("..");
子衿沉夜
炎炎设计
LEATH
相关分类