Spring boot mysql run db dump code on startup - java

I want to run the db dump code in the txt file while Spring boot application start. How can i do this?
otherwise i must copy-past and run db dump code to the mysql cli with manually.

if you want to LOAD data to database, i prefer to use Liquibase
you can load your data from .csv / .yml / .json / .sql
you can run it either before JPA Create Table or after create table.
So if you have a Team you all can have same data and table
if you want to DUMP your database, use liquibase too,
but why you want to dump your data if you have stable data master and it will automatically created everytime you run your app ?

Related

How to create table postgresql Heroku?

I have database postgresql in Heroku and i have local app. My entity is "Product".
When i wanna open my application in spring boot i get ERROR: relation "product" does not exist.
I dont have any idea how create new table "product" in postgresql.
In mysql everythink is good
You can with do it manually by running heroku pg:psql and then running the appropriate SQL statements. Or you can use a migration framework in your app.
For more information on running database migrations see the Heroku docs.

Configure spring batch without persisting metadata

I need to to change the spring batch application where I don't need to persist in the spring batch metadata tables, instead I need to use the in memory metadata.
My application is not Spring-Boot application, and I am using java configuration for spring.
Also I need to persist into the application tables so I need to use datasource.
Add in-memory DB to your Gradle project dependencies, for example, h2 :
compile 'com.h2database:h2:1.4.194'
Batch automatically will store the metadata in h2.

Entries in JBPM Tables

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.

ElasticSearch Schema Migrations

When we write an application, we also write migrations for database schema and data, we use liquibase for that.
For example I am deploying an application locally as developer on my machine, application uses elasticsearch, but before adding some data I need to execute some query/mappings.
So, I want to add that query/mappings to some files, so, when another developer will deploy application on his machine, that query will be executed automatically.
What tools/library are using for migrations ElasticSearch schema?
I created a long time ago a project I'm still maintaining which creates an index with all settings and mappings if it does not exist at startup.
elasticsearch-beyonder is available at https://github.com/dadoonet/elasticsearch-beyonder.
For now, it works only with a TransportClient but I'm planning to add support for the Java REST Client as well.

how to do some action(like create database) while deploying the war file(java) into tomcat server

At the time of deploying the war(java war file) file into the tomcat server, I want to create table and insert data into table (i am using mysql).
You have multiple options :
you could deploy your application with a script (like an Apache Ant script) and include the necessary SQL code to create and populate your database
You can also check for the existence of the table at startup of the application and create it if needed. This article suggests some options to perform tasks at startup of a web application.

Categories

Resources