-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Creating new database using hibernate
PostPosted: Tue Oct 09, 2007 1:19 am 
Newbie

Joined: Tue Oct 09, 2007 1:02 am
Posts: 5
Hi,
I am currently developing a admin console for my project. For that I am required to create databases and tables in that databases. I am using JavaServerFaces with Hibernate to achieve the task. My problem is that I can't find a way to create databases using hibernate. As I have read, I can certainly create tables in the (already created) database using SchemaExport utility, but I didn't find any material to create database using hibernate. Please help!!!
-Nirav


Top
 Profile  
 
 Post subject: Creating new database using hibernate
PostPosted: Tue Oct 09, 2007 6:57 am 
Newbie

Joined: Fri Aug 31, 2007 11:58 am
Posts: 19
What do you mean by can't find a way to create databases using hibernate.
you have Hibernate tools jar which you can say invoke from your ant task for the Schema Export.
This essentially mean you have Java Classes and Mapping done and want Hibernate to create database according to your mapping meta data.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 09, 2007 7:18 am 
Newbie

Joined: Tue Oct 09, 2007 1:02 am
Posts: 5
My MS SQL Server has no user-created databases .i.e newly installed. I tried creating tables using SchemaExport. But it gives error as the database in which tables are required to be created doesn't exists. Also it doesn't creates that database on its own.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 23, 2007 4:22 am 
Newbie

Joined: Fri Oct 12, 2007 2:58 am
Posts: 3
Any answers to this? I am stuck up on the same issue.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 23, 2007 4:51 am 
Newbie

Joined: Fri Aug 31, 2007 11:58 am
Posts: 19
Generally we just create tables or to say Schema from Hibernate SchemaExport and not the Database.
You should get some "Cannot open connection" as hibernate does not know where to connect to.

Not Sure as how to create database instance from hibernate but this is not a common practise.

Anyway just create a DB instance and then everything should be fine. No need to remain Stuck on this!

_________________
Note:Don't forget to rate,if useful.

Blog:http://elope.wordpress.com/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 23, 2007 4:51 am 
Newbie

Joined: Fri Aug 31, 2007 11:58 am
Posts: 19
Generally we just create tables or to say Schema from Hibernate SchemaExport and not the Database.
You should get some "Cannot open connection" as hibernate does not know where to connect to.

Not Sure as how to create database instance from hibernate but this is not a common practise.

Anyway just create a DB instance and then everything should be fine. No need to remain Stuck on this!

_________________
Note:Don't forget to rate,if useful.

Blog:http://elope.wordpress.com/


Top
 Profile  
 
 Post subject: Creating new database using hibernate
PostPosted: Tue Oct 23, 2007 5:03 am 
Newbie

Joined: Tue Oct 09, 2007 1:02 am
Posts: 5
I have got a solution to it!!!
Get the Connection object from hibernate session object through following code:

Connection con = session.connection();

and u r done :-) Now u can create a Statement object as in JDBC from Connection object and execute that statement. U can execute any DDL query using this statement object.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.