• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

create new .mdb file

 
rajesh mahendran
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just need to know that how can a create a new database file (.mdb) file dynamically using a java program anyone please help me thanks in advance....
 
Alexander Bondarev
Greenhorn
Posts: 12
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know two ways:
1) Create a new database in Microsoft Access and save it in the file template.mdb. Then to create a new database just copy template.mdb and rename it.
2) If you want to have full control over the database creation then use Jacob - Java COM Bridge and create a database through the DBEngine.CreateDatabase method.
 
rajesh mahendran
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alexander Bondarev wrote:I know two ways:
1) Create a new database in Microsoft Access and save it in the file template.mdb. Then to create a new database just copy template.mdb and rename it.
2) If you want to have full control over the database creation then use Jacob - Java COM Bridge and create a database through the DBEngine.CreateDatabase method.



can you just elaborate it in a detailed manner..ie) with a java program..
 
Scott Selikoff
author
Saloon Keeper
Posts: 4015
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Alexander's answer is self-explanatory. If you need assistance copying files, there are plenty of ways to do this in Java.
 
rajesh mahendran
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
explain it with a simple java code so that i can understand



will it generate a blank database with name abc or what else should i do to create...
 
Alexander Bondarev
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will probably get an exception in the line 4,

if the database file 'E:/dbbb.mdb' doesn't exist. Anyway you can run your code and see it. As I know SQL in Microsoft Access doesn't support the CREATE DATABASE command.
 
rajesh mahendran
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the how can i proceed on with what is the way to create it... in ms access anyone please help me...
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There really isn't much to add to Alexander's suggestions.

The first one is probably much easier. Create an empty MDB file somewhere and store it with your application (it could be bundled in your jar file). When you need a new database, just copy this file into the desired location.
 
Wei Dai
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. java.io.File copy blank mdb file

2. free Java Library for MS Access at http://jackcess.sourceforge.net/
Database.create(new File("new.mdb"));
3. commercial JDBC driver for MS Access at http://www.hxtt.com/access.html
sql: create database newfile;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic