I know these errors are occuring at compile time..i know how to use try-catch-finally . the problem is..how do i connect to the database..
If i want to connect to oracle 9i or 10g using type1 driver(Microsoft ODBC connection) creating dsn name and trying to connect to the database, the driverclass is not loading and its giving
Exception in thread "main" java.lang.NoClassDefFoundError: Jdbc/java
Here is the program:
import java.sql.*;
public class Jdbc{
public static void main(String args[]) throws Exception{
Connection conn=null;
try{
String driverclass="sun.jdbc.odbc.JdbcOdbcDriver";
String url="jdbc:odbc:custdsn";
String username="system";
String password="admin";
Class.forName(driverclass);
conn=DriverManager.getConnection(url,username,password);
System.out.println("connection established");
}
catch(Exception e){e.printStackTrace();}
finally{
conn.close();}
}
}