?
Solved

Java, MS Access Database (DNS less connection and more?)

Posted on 2005-03-26
8
Medium Priority
?
805 Views
Last Modified: 2011-10-03
Experts, this is multi-part question, so I'm giving max points:

I am trying to develop some personal software that will allow people to track certain activities during the year.  And, I naturally need a database to store the information in.  I have chosen MS Access as my database since obviously there won't be multiple user connecting (will be installed on individual pcs), no high volume transactions, and it a simple database.  I've searched other articles in EE for Java and database connections, but I haven't found anything on DNS-less java connections.  I normally do dnsless connections when I'm doing my ASP programming and wondering if there's anyting similiar.  So, can someone straighten me out on these questions:

1)  Does java support DNSless connections to an access database? if so, what' the code?

2)  If I install my software (compiled code and ms database)on a computer that doesn't have MS Access installed, will the program still know work? Will it still be able to read and write to database w/o the computer knowing it's a database.

3)  If I must use a DNS to connect to the database, how do I get the DNS installed on the computer I'm putting my code on w/o having to actually to through the Control Panel and install the DSN?  Is there anyway with my installation program that I can add the DNS?

4) Are there any other database options that someone would recommend.  I would eventually like to sell this product and don't want the buyer to have to buy any other databases for it to work.

Thanks -- Java Infant
0
Comment
Question by:jrram
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 15

Expert Comment

by:aozarov
ID: 13638240
1. When you are creating a connection you can provide the ip address instead of the hostname.
In that case DNS lookup will not take place.
2. I don't understand. If your application is storing data in DB how do you want it to work without it? If you interact with Acess via ODBC then you can have your DB hosted on any machine that supports ODBC.
3. you can always add the mapping ip to host in the hosts file.
4. When you use ODBC you can later on replace Access with any other Database that supports it (Oracle, MySQL, ...).
0
 
LVL 4

Expert Comment

by:91mustang
ID: 13639568
yes it is possible to connect witjout a dsn:

here is some code that will work for you:
Just change the word database to the path of your database:
(ie. C:/data/database)
change the password to your password (only nessecary if the DB is password protected;

Modify the query to reflect the query you want.
This will display you the users in the DB
try{
                        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //load the Jdbc driver
                        Connection con1 = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=Database","dba","sql"); //get a connection
                        Statement stmt = con1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
 String query ="select f_name,l_name from users";
                        ResultSet rs1 = stmt.executeQuery(query); //execute query
                        while(rs1.next()){
                        System.out.println( rs1.getString("f_name")+" "rs1.getString("l_name")+" is is the database");
0
 
LVL 4

Expert Comment

by:orhanbaba
ID: 13650408
String url = "jdbc:odbc:MS Access Database;DBQ=" + application.getRealPath( "db\\form.mdb" )

i have the same problem and worked fine look at it.
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_20807548.html
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 13

Author Comment

by:jrram
ID: 13659266
ok, i'll investigate the last two solutions presented in regards to the DNS-less connection,

Anyone have anything for the "

2)  If I install my software (compiled code and ms database)on a computer that doesn't have MS Access installed, will the program still know work? Will it still be able to read and write to database w/o the computer knowing it's a database.

3)  If I must use a DNS to connect to the database, how do I get the DNS installed on the computer I'm putting my code on w/o having to actually to through the Control Panel and install the DSN?  Is there anyway with my installation program that I can add the DNS? " questions?

I guess I'm wondering how programs like Quicken or Money store data?  I looked in the directories where i have these apps installed, and I don't see any reference to any known databases.
0
 
LVL 4

Expert Comment

by:91mustang
ID: 13661201
2) MS access does not need to be installed on the target machine.
0
 
LVL 4

Expert Comment

by:91mustang
ID: 13661212
3) dont know how well it will work for your situation, as it is in VB:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q184608
0
 
LVL 13

Author Comment

by:jrram
ID: 13688835
Will reward points by 4/5/05.  I need a little more time to investigate solutions.  91 mustang, where would the password username/password go in the connection string you provided?  could you surround it with brackets in the correct location.

Connection con1 = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=Database"[username],[password]"dba","sql"); //get a connection?
0
 
LVL 4

Accepted Solution

by:
91mustang earned 2000 total points
ID: 13689710
Connection con1 = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=Database","[username]","[password]"); //get a connection


Sorry should have mentioned that before.

cheers
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

801 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