I am trying to connect my sql server database to my code in java.
To get started I want to just make sure I can connect to the database via DSN but I am getting the error:
java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
Here is my code:
package javaapplication1;
import java.sql.*;
public class JavaApplication1 {
public static void main(String[] args)
{
Connection con;
Statement stmt;
ResultSet rs;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:SQLACCESS");
System.out.print("CONNECTION SUCCESSFUL");
}catch(Exception e)
{
System.err.println(e);
}
}
}
The DSN named "SQLACCESS" does not require a username or password. How should I go about connecting the two?