我从4天以来一直在寻找这个问题,但找不到合适的答案。我正在使用java 8和sql server 2008。 java.lang.ClassNotFoundException sun.jdbc.odbc.JdbcOdbcDriver
import java.sql.*;
public class DataConn {
public static void main(String[] args) throws SQLException,ClassNotFoundException {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:login_DSN");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("Select * from Simple");
while (rs.next()) {
int x = rs.getInt("Rollno");
String name = rs.getString("name");
String city = rs.getString("city");
System.out.println("Roll no \t\n" + x + "name \t\n" + name
+ "city \t\n" + city);
}
rs.close();
st.close();
con.close();
} catch (Exception e) {
System.out.println(e);
}
}
}