Link to home
Start Free TrialLog in
Avatar of orhanbaba
orhanbaba

asked on

How can I connect MSACCESS database without dsn and physical address?

for example
I wont give fullpath
DBQ=/myweb/data.mdb
asp example
Set bag=server.CreateObject("ADODB.Connection")
bag.open("DBQ=" & server.MapPath("db\form.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}")

it will be look like this
ASKER CERTIFIED SOLUTION
Avatar of kennethxu
kennethxu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi.
if you create a system DSN object to your Database you can use this:

        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            connection = DriverManager.getConnection("jdbc:odbc:[DSN Name]", "", "");
            statement = connection.createStatement();
        }
        catch(ClassNotFoundException classnotfoundexception)
        {
            System.err.println("Cannot find the database driver classes.");
            System.err.println(classnotfoundexception);
        }
        catch(SQLException sqlexception)
        {
            System.err.println("Cannot connect to this database.");
            System.err.println(sqlexception);
        }

regards
Javier
Sorry I didn't read the question properly, :c)