First, to hookup with MS Acces you do the same basic thing. Create a DSN for the MS Access DB your trying to access and then use
the appropriate drive for MS Access. IE: not the sun.jdbc.....
Second, here is some servlet code that gets a connection for MySQL:
import java.sql.*;
/**
* This is an example of how to create a connection using MySql JDBC
* drivers.
*/
public class MySQLCon
{
/* Declare private variables */
private Connection con;
private Driver MySQLDriver;
/*
Connection object for MySQL.
MySQLCon.GetCon returns a connection object to be used for preparing SQL statements, etc.
MySQLCon.SetCon creates an initial connection. Called automatically if GetCon is called before a connection is set
*/
public MySQLCon() throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException {
}
public synchronized Connection getCon() throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException {
if (con == null)
setCon();
return con;
}
public synchronized void setCon() throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException {
/* Set up JDBC */
if (con != null)
return;{t
MySQLDriver = (Driver) Class.forName("org.gjt.mm.mysql.Driver").newInstance(); ext2}
/*Connect to DB
Replace databasename with the name of your database
Replace myusername with your username
Replace mypassword with your password */
con = DriverManager.getConnection("jdbc:mysql://mysql.kgbinternet.com/databasename?user=yourusername&password=yourpassword");
/* Done connecting to DB */;
}
public synchronized void setCon(Connection connect) throws SQLException,ClassNotFoundException,IllegalAccessException,InstantiationException
{
con=connect;
}
}