JAvaアクセスデータベースへの接続(パスワード付き)


public class IpAddress {
private String userName = null;
private String password = null;
private String url = "jdbc:odbc:driver={microsoft access driver (*.mdb)};PWD=abc;dbq=";// E:/logdata.mdb
// private String url = "jdbc:odbc:driver={microsoft access driver (*.mdb)};PWD=abc;UID=abc;dbq=";// E:/logdata.mdb
private String driver = "com.hxtt.sql.access.AccessDriver";
private static Connection con = null;
private static Statement sta = null;
private static IpAddress access = null;
private String hql;

private IpAddress() {
   url = url + FiltersUtils.getFiltersUtilsInstances().getIpAddressPath();
   con = getConnection();
   try {

    sta = con.createStatement();
   } catch (Exception e) {
    System.out.println("FW   : Error: Could not create   Statement");
   }
}

public static IpAddress getIpAddressIntances() {
   if (access == null)
    access = new IpAddress();
   return access;
}

public Connection getConnection() {

   try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection(url);
   } catch (Exception e) {
    System.out.println("FW   : Error: Could not create   Connection");
   }

   return con;

}
}