OK fellas for once and for all....
if you have a an access database and you want to connect it with JAVA or JSP
you do the following
go to control panel and open ODBC data source....click on tab user DSN
click on MS access and click on Add
Select MS access again Click Finish...i will aks for a datasource name
Give it a name...such as 'phonedirectory' and then Click on Select button
and select your msaccess database in your directory example phonebook.mdb
NOW you have a data source connected to your access database ...
NOw in your JSP or JAVA program write the follogin code..
try {
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Connection con =
DriverManager.getConnection("jdbc:odbc:phonedirectory");
String sql = "SELECT * FROM phonenumbers;"; // this is an example of a
table inside the phonebook ms access database
System.out.println( "set the SQL");
Statement stmt= con.createStatement();
System.out.println( "SET THE STATEMENT ");
ResultSet rs=stmt.executeQuery(sql);
System.out.println( "Executing SELECT query ");
while (rs.next()) {
String s = rs.getString("name");
String n = rs.getString("number");
}
con.close( );
} catch( Exception e ) {
System.out.println(e);
System.exit( -1 );
}
HOPE this helps
panos
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com