Results 1 to 10 of 10
- 07-28-2011, 10:32 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 26
- Rep Power
- 0
How to create database through java program.??
hello everyone,
I have made an application in swing which uses MySQL database. Now I want that whenever my app is made to run on a new system for the first time, the app asks for the ip and port number of mysql from the user and creates the database and its tables automatically. Besides I have created a user in mysql, so it must create it accordingly. This should happen only for the first time.
How can it be done through java...????
- 07-28-2011, 12:37 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
By using a db user that has those rights and using sql commands.
- 07-28-2011, 04:06 PM #3
Member
- Join Date
- Jul 2011
- Posts
- 26
- Rep Power
- 0
ok, I got it....
thank you.
but can anyone tell me the logic that how the program is going to know that it is running for the first time on a system...???
Regards
- 07-28-2011, 04:20 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Check if any of the tables exist?
- 07-28-2011, 11:54 PM #5
Senior Member
- Join Date
- Jan 2011
- Location
- Rizal Province, Philippiines
- Posts
- 167
- Rep Power
- 0
You have several options, one is using the standard JDBC connection(non-hibernate) and the using Hibernate.
- 08-25-2011, 04:57 PM #6
Member
- Join Date
- Jun 2011
- Posts
- 59
- Rep Power
- 0
Hi everybody......
I have same problem, but I want to create MS Access 2007 (.accdb) database. When my application will run for the first time, the database should be create with some tables.
I have tried by following code, it created .accdb database, but when I tried to open the database it shows unknown access format.
Java Code:FileOutputStream file = new FileOutputStream("databasename.accdb");
How can I do it?
Thank you.
- 08-25-2011, 05:13 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Unless Access provides you with an interface in Java to create a database then you won't be able to do it.
Either that or you'll have to rely in there being an existing access database you can add tables to.
Which reminds me, is there a proper JDBC driver for Access?
If you are using the JDBC-ODBC bridge then that's another big problem.
- 08-25-2011, 06:38 PM #8
Member
- Join Date
- Jun 2011
- Posts
- 59
- Rep Power
- 0
- 08-25-2011, 06:47 PM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
I only know of the bridge for access. I don't use Access, so can't say if there's a "proper" driver.
As for creating the db file via Java, you'll have to do some hunting, but I very much doubt you'll find anything that does it.
Why not use something like Derby instead? A proper Embedded database (presuming it's not for multiple users).
- 08-25-2011, 07:10 PM #10
Member
- Join Date
- Jun 2011
- Posts
- 59
- Rep Power
- 0
Similar Threads
-
Java Barcode Program with Oracle database
By techsing14 in forum Java 2DReplies: 4Last Post: 02-25-2011, 07:37 AM -
My difficulty to create a database with a java program
By 3c4hy0 in forum JDBCReplies: 2Last Post: 08-13-2010, 11:42 AM -
[Help] How to create a database inventory program
By soul303 in forum NetBeansReplies: 1Last Post: 05-05-2010, 03:26 AM -
Create a folder within a java program.
By yellowfire7 in forum New To JavaReplies: 2Last Post: 10-26-2009, 10:14 PM -
How to connect a Java program with MySQL database?
By Ms.Ranjan in forum JDBCReplies: 2Last Post: 06-12-2008, 07:09 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks