I am currently trying to configure my Spring Boot application so it can talk with my H2 database through Hibernate. As far as I know, the application manages to succesfully connect to the database but it is then unable to find the default database schema as defined in my application.properties file. I have already tried manually creating the database schema through RazorSQL but this did not work.
application.properties:
spring.datasource.url=jdbc:h2:~/dndmp;AUTO_SERVER=TRUE
spring.datasource.platform=h2
spring.datasource.continue-on-error=true
spring.datasource.username=DNDMP
spring.datasource.password=tttt
spring.jpa.properties.hibernate.default_schema=dndmp
spring.jpa.properties.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
Use:
spring.jpa.hibernate.ddl-auto=update
Related
I have spring boot application that need to be deployed on PCF. I want to use H2 database for local testing but after deployed in PCF I will be using SQL server. I have a schema that need to be used for each database. So, I have two schema.sql file one for H2 and another for SQL server. How can I tell spring for local profile schema-H2.sql need to be used and for profile cloud schema-sqlserver.sql need to be used.
You can set the spring.datasource.platform to differentiate the schema and data sql file.
eg,
spring.datasource.platform=h2
then the file name should be data-h2.sql and schema-h2.sql
Make sure you set spring.datasource.initialization-mode=always
I have created a spring boot project in eclipse with a H2 embedded database and JPA. Inside my resource folder I'm using import.sql to populate the tables created in my entity package.The spring web application and database runs fine as I can check it but I want to know if it is possible to check this database in Intelij DataGrip like I can when I do this:
localhost:8080/h2-console
In my application.properties in my spring project I have this:
spring.datasource.url=jdbc:h2:file:./database/suppliersDB;
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.DefaultNamingStrategy
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create
In my Intelij Datagrip I add a data source H2 and give it the url and test connection and it says ok but doesn't show any of the tables and when I run a query in the DLL it says table doesn't exist
And I know I should probably shouldn't be using Intelij IDE since my project is in eclipse but it is just an experiment and it is frustrating me I can't get it working in Datagrip.
Also the embedded database file stored by eclipse is an .mv.db file which maybe the problem i'm not sure!
Any help would be much appreciated!
You cannot do it because the database you created is in-memory.
I am trying to integrate JBPM with different databases ,so I wanted to ask:
Does JBPM requires any specific Database ?
How to maintain database in JBPM ?
For Example if we need to execute delete statement, where do we set it? In JBPM or in Hibernate?
JBPM use with default a inmemory H2 Database.
But you can configure it to make use of other relational database systems. I was able to use Postgres and MS SQL so far.
Please find further instructions about DB config with in the offical docs: https://docs.jboss.org/jbpm/release/7.3.0.Final/jbpm-docs/html_single/#_using_a_different_database
JBPM comes configured with H2 Database by default, you can change through
persistence.xml the default dialect
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
configure DS on standalone.xml
<jta-data-source>java:jboss/datasources/jbpmDS</jta-data-source>
When you start your JBoss instance, it should refresh your database ddl's.
I have installed Umbraco via WebMatrix, and entered "server=(localdb)\v11.0;integrated security=true" as a connection string. The site works fine, but I can't find the database that Umbraco have created. When I open the (localdb)\v11.0, it's not there.
I have tried searching whole system with *.mdf. but no luck. Where can the data be?
I am using umbraco 4.8.0
Most likely the database is in the user profile folder of the account that Umbraco is running under. See this post for more complete explanation. You may also want to look at this other post about why LocalDB by default puts the database file in the root of the user profile of the account it runs under.
I have found it. With no Database defined, SQL server uses the first or the default database in the list, which appears to master database. SSMS and such, don't display tables of system objects, so I found the tables by querying the database.
The H2 database used in the Java Todo List tutorial is the following:
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
How do I modify the configuration file to use a persistent database as opposed to an in-memory version. Do I need to setup an entirely separate DB or can I modify the db.default.url property?
I'm using Play! 2.0.3.
I found the solution.
To create a file database, modify the following:
From
db.default.url="jdbc:h2:mem:play"
To
db.default.url="jdbc:h2:file:data/db"
Where data/db is broken down into:
data/ The folder location of the database files relative to your project root.
db The name of your database files.