Solved

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

Posted on 2003-11-24
3
596 Views
Last Modified: 2008-03-17
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
0
Comment
Question by:orhanbaba
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
kennethxu earned 125 total points
ID: 9815242
try
url = "jdbc:odbc:MS Access Database;DBQ=db\\form.mdb"

But I don't think this will work for jsp because the current directory is the directory where server is started. not you jsp directory. you'll need to use application.getRealPath( "db\\form.mdb" ) to the the full path. So it should be:

String url = "jdbc:odbc:MS Access Database;DBQ=" + application.getRealPath( "db\\form.mdb" )
0
 
LVL 6

Expert Comment

by:jarasa
ID: 9816668
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
0
 
LVL 6

Expert Comment

by:jarasa
ID: 9816671
Sorry I didn't read the question properly, :c)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

A Short Story about the Best File Recovery Software – Acronis True Image 2017
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now