db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: creating a database from my application, best practice
Date Mon, 23 Jan 2006 18:42:38 GMT
Also Cayenne PetStore example contains code that bootstraps the  
database when the web app is deployed for the first time:


It can be used as a template for new apps. It checks if the Derby  
schema is present, and if not, sets up the schema from Cayenne  
mappings, and then loads the initial data from a SQL file. Of course  
you'll get the most synergy out of it if you are otherwise using  
Cayenne for persistence, but this can be used independently from the  
rest of your application as well.


On Jan 23, 2006, at 1:00 PM, Manjula G Kutty wrote:
> Ingimar Erlingsson wrote:
>> Hello!
>> Thank you for derby!
>> I have a question, did follow the example in 'db-derby- 
>> \demo\simple\simpleapp.java'
>> in the demo only one table is created.
>> My database, which I have now in mysql has 8 tables and  
>> relationships between them.
>> I would like to create my database from within my application:
>> And my question is: must I do the following for all 5 tables ->  
>> s.execute("CREATE TABLE AP .......");
>> and for all their relationsships or can I put all these in some  
>> property or txt file and fetch them from there ?
>> And the same for all my relationships. And package that property- 
>> file or txt file with my application jar ?
>> Or can I create a procedure in the database that is called which  
>> creates all my tables and their realtionships.
>> Or should I use hibernate ( never tested hibernate though) and  
>> include som xml file ?
>> regards, i
> Hi,
> You can write all your SQL statements in a sql file and just pass  
> that sql file name as a string in your application. I think your  
> application is in java, then you can pass the file name like this
> org.apache.derby.tools.ij.main(new String[ ] {"-fr", "schema.sql"});
> Thanks
> Manjula

View raw message