I need to setup a MySQL database for a DataNucleus properties file:
javax.jdo.PersistenceManagerFactoryClass=org.datanucleus.api.jdo.JDOPersistenceManagerFactory
datanucleus.metadata.validate=false
# Enable these lines if persisting to ODF
#javax.jdo.option.ConnectionURL=odf:file:tutorial.ods
#javax.jdo.option.Mapping=odf
# Enable these lines if persisting to RDBMS (HSQLDB)
javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
javax.jdo.option.ConnectionURL=jdbc:mysql://myserver.com:3306/myDb
javax.jdo.option.ConnectionUserName=userName
javax.jdo.option.ConnectionPassword=password
# javax.jdo.option.Mapping=hsql
datanucleus.autoCreateSchema=true
datanucleus.validateTables=false
datanucleus.validateConstraints=false
Can anyone please tell me the steps on how to set it up for this particular purpose?
Since you have autoCreateSchema enabled, you do not need to create the schema. All you need to do is create the database itself. Install mysql if necessary, log in to mysql as root and then issue the create database command. If you do not have root access, consult the documentation or the administrator for your server. You can find many tutorials online for this task, please read them before asking further questions.
Related
I am surprised I haven't found an SO question that answers this. I am trying to connect a springboot/JPA application to an SQL Server on my local machine. I have the application setup so that it can connect to a database if it it exists, but if I change the JDBC URL to create the database if it doesn't exist then it fails. Here is what the properties look like when it fails.
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=testing;createDatabaseIfNotExist=true;
spring.datasource.username=hello
spring.datasource.password=Hello1234
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.database-platform=org.hibernate.dialect.SQLServer2008Dialect
spring.jpa.show-sql=true
Here is a snippet of the error I receive when starting the app:
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user
'hello'. ClientConnectionId:971a3369-258b-4713-bddc-cda559b9fe94 at
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
~[mssql-jdbc-8.4.0.jre11.jar:na] at
com.microsoft.sqlserver.jdbc.TDSTokenHandle
If anybody has any thoughts as to how I can change this so the database is created if it does not exist I would be very thankful. Thanks in advnace.
I don't think a database can be created using JPA.
It has to be created manually or in some other ways, but JPA won't do that for you.
And it would be a bad practice as well to create the database using the application itself, and the use of same credentials.
Yes, definitely you can auto-create a database with JPA for that
spring.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=testing;
createDatabaseIfNotExist=true;
line should be changed to:
spring.datasource.url=jdbc:sqlserver://localhost:1433
/testing?createDatabaseIfNotExist=true
In practice your application should never create your database so its not really a problem most of the time(Outside small databases like sqlite3). Different databases would handle this situation differently as well.
In your case I do not see this as a valid jdbc parameter in the documentation.
I would recommend creating the database in advance with a privileged user separate from your application user.
I deployed a simple Jpdl (JBPM4.4) and when i check the jbpm database. I found entries in JBPM4_DEPLOYMENT, JBPM4_DEPLOYPROP tables but not in anyothe table.
I want to understand when the entries goes into the other tables of jbpm database.
You will find the database scripts for a lot of the supported
databases in the DB subproject. The database scripts for PostgreSQL
are found in the folder '${JBPM_SDK_HOME}/jbpm-db/build/mysql/scripts.
The creation script is called 'postgresql.create.sql'. Using
DBVisualizer, you can load this script by switching to the 'SQL
Commander' tab and then selecting 'File->Load...'. In the following
dialog, navigate to the creation script file.
Resource Link: https://docs.jboss.org/jbpm/v3/userguide/thejbpmdatabase.html
You will also get mysql data import related info step by step in this link.
How can use of database PostgreSQL in Liferay and connection therewith, reading, programming in the VM to display contents of the database.
There are following two way using which you can change liferay database.
At start up liferay provides the option using which we can change liferay database.
Following is the steps for the same.
1.1) Create a database in postgresql(like lportal).
1.2) Select the change database option at liferay start up.
1.3) Enter your databse url,username and password.
1.4) To run the liferay setup again you just need to change the following property in portal-setup-wizard.properties((check attached screen shot for path of this file)
Change the following value false to true
setup.wizard.enabled=true
1.5) When you will run the sever it will ask you for the admin user configuration and exactly below that there is option to change the database using which you can change the database.
OR
You can create a file with name portal-ext.properties in Liferay root folder(check attached screen shot).
Add following database configuration.
#
# Postgresql
#
jdbc.default.driverClassName= Postgre Drive
jdbc.default.url= Database url
jdbc.default.username= database username
jdbc.default.password= database password
For more details check following url
http://www.liferay.com/community/wiki/-/wiki/Main/Database+Portal+Properties
Hope it may help you.!!
Was wondering, what steps am I missing to get a jdbc embeded h2 database working in my play application? Following these docs.
So far editted Application.conf file to contain this:
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:databases/test"
db.default.user=test
db.default.password="testtest"
Next I created a libs directory and added the jar file
h2-1.3.174.jar
Is this necessary or does the provided driver handle all types of h2 databases (embeded and server - I know it handles in memory)?
Now in the controler how can I access the database? Do I have to start/shutdown the database?
I know I can get connections from the getConnection() method in play.db. But everytime I execute a statement through this connection I get an exception saying no data is available. If I then check - looks like directory
databases/test
was not created so no database files exist.
What am I missing?
H2 works out of the box. Just create a new project in the terminal.
Otherwise, to your listing:
I think you should change db.default.url="jdbc:h2:databases/test" to db.default.url="jdbc:h2:mem:play"
don't need to create lib directories. It's all handeled by the build in dependency mgmt sbt
Just use the model objects and call save/update. No need to call start/shutdown
you are in a framework, it's all there ready for you...
I think you should start reading the documentation from the beginning to the end and examine the example applications. It's all there what you are looking for.
In addition to myborobudur's answer I'll only mention, that you don't need to use memory database, as you can for an instance use file storage (Embedded) or even run H2 as a server and then connect to it with TCP in Server Mode... Everything is clearly described in H2 documentation.
We are using JBoss 4.0.3 SP1 using Hypersonic as its internal storage engine (timers, queues, etc.)
The database is no longer accessible (most likely data corruption) giving error; Caused by: org.hsqldb.HsqlException: old version database must be shutdown.
Is there a way or command to shutdown the database to recover the data (~150MB) stuck in the flat file?
Edit
Resolved the connection problem by downgrading to Hypersonic 1.8. How ever the database itself is corrupt. You have rows with duplicate keys, and lots of null fields. Having read this article and this one, i'm in the process of changing the default JBossMQ database to MS SQL
According to the hsql documentation the command is SHUTDOWN. As far as I remember, hsql saves the data as a set of sql queries, so you need to have a look on the file.
Notice that according to JBoss,
Hypersonic(HSQLDB) SHOULD NOT be used
in production at all. It is not
suitable for production use.