my dog learned polymorphism*
The moose likes Java in General and the fly likes How to open Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to open ".mdb" file(access database) by java code" Watch "How to open ".mdb" file(access database) by java code" New topic
Author

How to open ".mdb" file(access database) by java code

aminur rashid
Ranch Hand

Joined: Sep 21, 2001
Posts: 79
I have a .mdb(acces file ).I want to open this mdb file by java programme .This means that whenever i run my java code with the path of mdb specified in the code, the mdb file should open up .Can any one help me out how to do this?
Thanks
Amin


Regards<br />Aminur
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
You have to use JDBC. There is a little bit of learning that you have to do if you've never used JDBC. You also have to set up your environment for your DSN. There is a JDBC tutorial with examples at Sun's site.
------------------
Bosun
SCJP for the Java� 2 Platform


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
You can also access it without a DSN using:
jdbc dbc:MS Access Database;DBQ="C:\\Somewhere\\DB.mdb"
If you are using Microsoft Office 97 then replace "MS Access Database" with "MS Access 97 Database". If it doesn't work, go to your Control Panel and click on ODBC. Replace "MS Access Database" with whatever is there.
HTH
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
BTW, how do you get rid of the :O ? is there a way to "escape" the smiley?
Daniel Walker
Greenhorn

Joined: Aug 09, 2001
Posts: 19
There is a box at the foot of the "post reply" page, in the "options" section. Click it.
------------------
daniel.walker
***i fear that i am ordinary...
...just like everyone...***


<B>daniel.walker</B><BR><I>***bleed in your own light...<BR>...dream of your own life...***</I>
Shubhrajit Chatterjee
Ranch Hand

Joined: Aug 23, 2001
Posts: 356
Originally posted by aminur rashid:
I have a .mdb(acces file ).I want to open this mdb file by java programme .This means that whenever i run my java code with the path of mdb specified in the code, the mdb file should open up .Can any one help me out how to do this?
Thanks
Amin

You have to follow these steps.
1. Create a system data source name using the odbc administrator of the windows machine you are using.
2. Load the sun.jdbc.odbc.JdbcOdbcDriver class(Since we are using JDBC type 1 connection)
3. Get a conection to the database
4. Create a statement object
5. Fire an SQL to obtain a resultset
6. Browse thru the resultset to obtain data and do your processing
7. Close the connection

------------------
Shubhrajit


Shubhrajit
Matthew Roth
Greenhorn

Joined: Jan 30, 2001
Posts: 19
Can java open an MS Access database without Access being installed on a computer?
The user will have to log in to my program with a password. I'm trying to figure out where the best place is to place the username and password. I thought I could place it into an Access database and then include that with the program when I distribute the program. I know a lot of people don't have Access.
I didn't think a text file would be the best place for username and passwords. Any suggestions would be appreciated. Thanks
Reuben Cleetus
Ranch Hand

Joined: Jul 13, 2001
Posts: 50
Yes, you can open an MS Access Database (*.mdb), without having Access itself installed on the computer. Remember, you're using JDBC to open the Database, which has nothing to do with Access.
Even if you choose to use JDBC DBC to get to your Access database, you still don't need Access installed.
Regards,
Reuben Cleetus.
Matthew Roth
Greenhorn

Joined: Jan 30, 2001
Posts: 19
Thanks Reuben, I thought that would be the answer but I wasn't for sure.
Thanks again,
Matt
aminur rashid
Ranch Hand

Joined: Sep 21, 2001
Posts: 79
Actually what answer i was expecting when i started the thread is given below as the code.Actually i was not talking of making a conncetion to the access file but to open the access file as such from the directory itself..i was expecting this code which i got somewhere in the Forum itself....3 cheers for the forum
Thank U all for the valuable contribution.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to open ".mdb" file(access database) by java code
 
Similar Threads
Cold Fusion Database Closing
change access db password through java.
create .mdb file through command
How to access MS-Access(.mdb) file in java program with MAC OS
MDB on error