Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / February 2005

Tip: Looking for answers? Try searching our database.

How to create Microsoft Access Database (.mdb) in Java

Thread view: 
Pony - 03 Feb 2005 07:31 GMT
I want to create a blank Microsoft Access 97 Database in Java and later
connect to it and create tables and insert data. I know how to connect to an
existing .mdb database, but I have no idea how to create one using Java. Can
you help me figure out how to make it. Thank you!
_Mario_ - 03 Feb 2005 08:51 GMT
>I want to create a blank Microsoft Access 97 Database in Java and later
> connect to it and create tables and insert data. I know how to connect to
> an
> existing .mdb database, but I have no idea how to create one using Java.
> Can
> you help me figure out how to make it. Thank you!

The only solution is to copy an existing empty mdb, connect to this and
create tables etc...
No way to create a mdb from code (also with MS VB!!).

Mario
John - 03 Feb 2005 12:32 GMT
>>I want to create a blank Microsoft Access 97 Database in Java and later
>>connect to it and create tables and insert data. I know how to connect to
[quoted text clipped - 8 lines]
>
> Mario

Do you think it would work if the OP read an empty mdb, stored the
binary, then used his application to spit out the same binary as a file
every time he wanted to create a blank database?

John
rkc - 08 Feb 2005 03:42 GMT
>>I want to create a blank Microsoft Access 97 Database in Java and later
>>connect to it and create tables and insert data. I know how to connect to
[quoted text clipped - 6 lines]
> create tables etc...
> No way to create a mdb from code (also with MS VB!!).

It's no help for the Java problem, but your wrong about MS VB.
You can create an ".mdb" file using either DAO or ADO/ADOX.
JavaJava - 03 Feb 2005 18:12 GMT
Hey Pony, I did some looking into this and found a way to do it.
(You'll want to thank  Albretch in comp.lang.java.programmer for this)

in order to CREATE a new db in Access you will have to:

To create a database for MS Access from Java do the following:

- Know what version of MS Access you have.
- Keep a blank (no tables, forms, etc...) copy of an .mdb
- Have a method in your Java app that will copy the (basically its your
template for databases) blank .mdb file to a new file, and the filename
will be the name of your database you want to create.
- Create the DSN on the fly by passing all driver config settings
inside the connect string.  Like so:

Connection conn =
DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver
(*.mdb)};DBQ=C:/MSAccess/<dbname>.mdb","<UsersId>","<password>");

If this doesn't work out for you, I'll throw together a quick sample
for ya and post it.

Josh
Pony - 04 Feb 2005 01:13 GMT
Thank you for the reply. I'll try this to see if it works. I'll contact with
you if this doesn't work.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.