0

I've been looking for this problem since 4 days and could not find an appropriate answer .I'm using java 8 and 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);
    }
}
}
Pranav Nair
  • 23
  • 1
  • 6

0 Answers0