Solved

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

Posted on 2003-11-24
3
599 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java cyclic graphs 15 212
some methods private some are not 8 220
authenticate preemptively soap ui option 3 158
Java Exception example issues 11 84
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 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