Hi All
I'm trying to access databaseusing
jdbc and i'm getting this error:
Exception java.lang.ClassNotFoundException must be caught, or it must be declared in the throws clause of this constructor.
Class.forName
sometime in this statment :
Class.forName( "microsoft.jdbc.odbc.JdbcOdbcDriver");
I put instead microsoft sun and i still getting the same error.
here the
java file:
import java.sql.*;
import java.lang.*;
public class myJdbc
{
public myJdbc()
{
String url="jdbc
dbc:sample";
String query= "SELECT * FROM PERSON ";
//boolean more;
Statement stmt ;
try
{
Class.forName( "microsoft.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection(url,"matt","matt");
stmt= con.createStatement();
ResultSet rs = stmt.executeQuery(query);
//while(more = rs.next())
while( rs.next())
{
int number = rs.getInt("PERSON#");
String firstName = rs.getString("FIRST");
String lastName = rs.getString("LAST");
System.out.println(number + " " + firstName + " " + lastName);
}
rs.close();
stmt.close();
con.close();
}
catch(SQLException ex )
{
ex.printStackTrace();
}
}
public static void main(String args[])
{
myJdbc my = new myJdbc();
}
}
thanks for your time.