Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't establish connection to Access db through my java program

Status
Not open for further replies.

KnightCoder

Programmer
Jan 30, 2001
16
0
0
GB
i am using windows 98, i have installed jdk1.3.

i have created a simple access database and created a DSN.

i need an example of any java code that establishes connection to an access database using the DNS and executes a simple query with a displayed result.

any help is welcome!

 
Don't know how much help this will be but here it is anyway.

-pete


Class.forName("com.ms.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection( "jdbc:eek:dbc:MYACCS", "", "");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while( rs.next()){
System.out.println(rs.getString("name") + ": " + rs.getString("email") );
} // while()

rs.close();
stmt.close();
con.close();

}catch(SQLException sex){
System.out.println("SQLException: " + sex.getMessage());
}catch(Exception ex){
System.out.println( "Exception: " + ex.getMessage());
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top