>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.
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.