-->
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.  [ 3 posts ] 
Author Message
 Post subject: AUTO-CREATE DATABASE MSSQL
PostPosted: Tue Nov 28, 2017 9:49 am 
Newbie

Joined: Tue Nov 28, 2017 9:42 am
Posts: 5
Hi,

I'm currently facing the following issue:

I would like to auto-create a MSSQL-database (MSSQL Server Express 2014).

I've set the following properties:

<property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:sqlserver://127.0.0.1\SQLEXPRESS;databaseName=mm_test</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>

This works well, if the database 'mm_test' already exists - i.e. it creates the table structure of the configuration-mappings.

However, how can I accomplish that the database mm_test will be automatically created, if it does not exist?

I've found the possibility to put a parameter into the connection-url e.g.

<property name="hibernate.connection.url">jdbc:sqlserver://127.0.0.1\SQLEXPRESS;databaseName=mm_test;createDatabaseIfNotExist=true;</property>

which does obviously not work for MSSQL-databases.

Also if I create a root-database hibernate configuration and run a HSQL - statement (CREATE DATABASE mm_test) in NetBeans, I get java.lang.IllegalArgumentException: node to traverse cannot be null!

Any hint appreciated,

Thanks,

Regards

Klaus


Top
 Profile  
 
 Post subject: Re: AUTO-CREATE DATABASE MSSQL
PostPosted: Tue Nov 28, 2017 10:28 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1630
Location: Romania
Hibernate does not create databases. The database has to be there.

More, you should use a tool like Flyway in production. Hbm2ddl is suitable for testing or creating the initial script only.


Top
 Profile  
 
 Post subject: Re: AUTO-CREATE DATABASE MSSQL
PostPosted: Thu Nov 30, 2017 5:59 am 
Newbie

Joined: Tue Nov 28, 2017 9:42 am
Posts: 5
Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.