Hello all, I've created a table with code, I want to know if it's possible to create alsoe the database instance from java or do I have to go to access and and create a file .mdb? This code works properly if the database instance is already created. I would like to check if the database exists and if it doesn't, I want to create it.
Any idea? Thx for your help.
By constantly trying one ends up succeeding. Thus: the more one fails the more one has a chance to succeed.
im pretty sure you can create a database from a Java app but it is easier to do it from Access if you can. i cant give you any help on doing it in code since i was able to avoid doing that. [ November 26, 2002: Message edited by: Randall Twede ]
Unfortunately, their is no elegant solution. The JDBC framework makes the assumption that the database already exists and provides no support for database creation. This is not surprising as for most databases, the amount of files and programs needed to make a database, and that need to be present for it to be used are huge and not really portable. There are some not-so-elegant-work-arounds though. 1. Use JNI to call native code that gets the job done. 2. For MSAccess, since everything is selfcontained in the .mdb, you could include an "empty" database in your jar file so that it is ready for you to use when you need it. The only problem is that you can't guarantee that the MSAccess ODBC driver on the new client is compatible with the version of access you packaged with your app. Anyway you look at it, Database creation is not really supported by java. Jamie
Joined: Jan 13, 2002
Thx Jamie for your answer, maybe that I can package different version of access and use the good one. So is it possible to know which veriosn of acces the client is using, and I will have to register the *.mdb with ODBC. Maybe that I shall include some readme.txt, it seems easier. :roll:
Hi, Is it possible to create a database because you will have to assign/create a DNS ( using OBDC datasource )to it,which you will do before you run your java code right?? I think only with Java it is not possible. Any one Please clarify.. Thanks Jyothi
Originally posted by Jyothi kidambhi: Hi, Is it possible to create a database because you will have to assign/create a DNS ( using OBDC datasource )to it,which you will do before you run your java code right?? I think only with Java it is not possible. Any one Please clarify.. Thanks Jyothi
Sounds correct. I don't know of any JDBC Drivers for accessing an MS Access DB without using ODBC. So there would be no way to create a MS Access DB using JAVA without going through the ODBC and there would be no way to create an ODBC connectin without the Database already being present. Wow, what a vicious circle that is. [ November 27, 2002: Message edited by: Gregg Bolinger ]
I just thought of this though. I don't know if you REQUIRE a MS ACCESS DB or your reasons for choosing it for you Database. But you may want to look into something like HSQLDB or something similar. It can be delivered with your Application/Applet, has a small footprint, and you can simply pass SQL Statements to it through JDBC to create your database and tables, etc.
Joined: Jan 13, 2002
Thx Gregg, I went trough your link, it seems great. I think that I will choose the Hypersonic SQL solution Thx again everybody