Results 1 to 2 of 2
  1. #1
    azzaiel's Avatar
    azzaiel is offline Member
    Join Date
    Feb 2009
    Posts
    57
    Rep Power
    0

    Default How to connect to msaccess?

    can some one please post a tutorial or a link to a tutorial on how to connect to msaccess database pelase :D
    It's easy to write a code that computers can understand...
    ... the challenge is to write a code that humans can understand

  2. #2
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    6

    Default

    For example you called your database management.mdb:

    Java Code:
    import java.sql.*;
    import java.sql.DriverManager;
    import java.io.*;
    
    public class MSDbConnector {
     private Connection conn=null;
    
        public Connection dbConnect() throws SQLException, ClassNotFoundException{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String url="jdbc:odbc:management";
            return conn=DriverManager.getConnection(url,"","");
        }
    
        public void closeConnection()throws SQLException{
            conn.close();
        }
    
    }
    Then you can create a new class where you can fully use this connector:
    Java Code:
    import java.sql.*;
    import java.util.ArrayList;
    import java.util.Properties;
    import java.io.*;
    
    public class MSDbFacadeJob {
    
    	Statement psth = null;
    	ResultSet res = null;
    	MSDbConnector conn = null;
    
    	public MSDbFacadeJob() throws Exception {
    		conn = new MSDbConnector();
    		psth = conn.dbConnect().createStatement();
    	}
    
    .....................
    your methods
    
    ..................
    }

Similar Threads

  1. Replies: 3
    Last Post: 04-30-2009, 09:28 AM
  2. how to connect with my GUI
    By doha786 in forum New To Java
    Replies: 2
    Last Post: 04-01-2009, 04:59 PM
  3. how to connect to sms modem?
    By glassball in forum Networking
    Replies: 3
    Last Post: 01-10-2009, 08:33 PM
  4. how connect
    By herfnai in forum JDBC
    Replies: 1
    Last Post: 08-18-2008, 06:34 AM
  5. MSAccess and hibernate
    By bbq in forum JDBC
    Replies: 3
    Last Post: 04-30-2008, 04:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •