Camunda tables not getting created on startup when I use Mysql - mysql

I start my project with spring boot and camunda and MySQL , but camunda tables cant create .
my config is :
spring:
datasource:
url: jdbc:mysql://localhost:3306/austira
username: root
password: root
jpa:
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
database: MYSQL
hibernate:
ddl-auto: update
server:
port: 9090
camunda:
bpm:
database:
type: mysql
then I face with this exception:
Caused by: java.sql.SQLSyntaxErrorException: Table 'austira.act_ge_property' doesn't exist
thanks for your help

Did you create the database austira after starting the database?
Does the user have access to it?
Have the tables not been created during startup or is it only failing later, after the tables have been created and the engine tries to use them (see / provide more startup logs)?
Here is a working setup against MySQL (on Docker):
https://github.com/rob2universe/camunda-mysql
(I changed the db name to camdb instead of austira)

Related

How do I enable mysql connection compression in spring boot application?

I have a spring boot application that is connecting to a MySQL db (MySQL 8.0). Here is the connection configuration in my application.yml file
datasource:
url: "jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}?useUnicode=yes&characterEncoding=UTF-8&autoReconnect=true&useSSL=false"
username: "${DB_USER}"
password: "${DB_PASSWORD}"
hikari:
maximumPoolSize: ${DB_MAX_POOL_SIZE}
I would like to enable compression on this connection pool. How can I achieve that? Not been able to find any documentation on this.
The connection parameter is useCompression. It is a boolean.
Refer to MySQL Connector/J Networking Configuration Properties: useCompression

Database connection failed: Error: ER_BAD_DB_ERROR: Unknown database 'database-1'

I created a MYSQL database in AWS RDS, and this is the config settings setup:
DB instance ID
database-1
Engine version
8.0.28
DB name
-
so as you can see, there isn't a db name. So now, when I go to create a table via my code, or even mysql workbench, since no db name is included, it fails with:
Database connection failed: Error: ER_BAD_DB_ERROR: Unknown database 'database-1'
I am trying this in code as well:
var mysqlconn = mysql.createConnection({
host: 'database-1.xxx.com,
user: 'username',
password: 'pw,
port: '3306',
database: 'database-1'
});
let createTable = "CREATE TABLE table_name (name VARCHAR(256),email VARCHAR(256),number INT(32))"
but it gives the above error. any advice / help is much appreciated
When creating the RDS instance you have the option to have RDS create an initial database. If you do not provide a value, RDS does not create a database at all (see image below). You'll need to connect to the instance and issue the command create a database yourself, e.g.
CREATE DATABASE mydb;

Spring application refuses to connect to my MySql database with specified username

I got some strange situation. When i start my spring boot app with application file:
spring:
jpa:
show-sql: true
databasePlatform: org.hibernate.dialect.MySQL5InnoDBDialect
hibernate:
ddl-auto: update
connection:
charSet: UTF-8
characterEncoding: UTF-8
useUnicode: true
datasource:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/deutschlerner_db?serverTimezone=UTC
username: root
password: root
I recieve the error:
java.sql.SQLException: Access denied for user 'mihailzubarev'#'localhost' (using password: YES)
"mihailzubarev" - is just my linux profile name, mysql doesn't have that username but does have "root" user.
This error i can reproduce just typing in terminal mysql -p it accepts default linux profile username and expectedly drops the same error. But I specified user name in my application file!!!
Futhermore it is possible to connet the database by defining a Bean in SpringBottApplication file and everything works fine
#Bean
public DataSource getDataSource() {
DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
dataSourceBuilder.url("jdbc:mysql://localhost:3306/deutschlerner_db?serverTimezone=UTC");
dataSourceBuilder.username("root");
dataSourceBuilder.password("root");
return dataSourceBuilder.build();
}
I got environtment variable which overrided username value

How to define two different database users in Quarkus for Liquibase

currently I'm trying to create a REST-Client with Quarkus and it's really amazing how cool this framework is. But now I'm having some problems with Liquibase.
I want Liquibase to access the database with an other user, than the datasource. In spring boot it would be something like this.
spring:
datasource:
driver-class-name: org.mariadb.jdbc.Driver
url: jdbc:mariadb://...
username: <app_user>
password: ${DB_PASSWORD}
liquibase:
default-schema: my_schema
user: <admin_user>
password: ${DB_ADMIN_PASSWORD}
Is it possible to configure this in Quarkus too?

hibernate ddl-auto don't work with MySql but it worked with H2

I have finished my spring boot application, and now I'm trying to deploy it with docker-compose. While developing I have used H2 in-memory DB and all was fine. Now I'm trying to switch data source to MySql and hibernate isn't creating any tables in MySql Database. Then my Spring boot app trying to do some actions and can't find any tables (because it wasn't created on start).
I have exceptions like
Caused by: java.sql.SQLSyntaxErrorException: Table 'db.test_run' doesn't exist
I tried to switch ddl-auto to create-drop or update and had the same result. My config is:
spring:
datasource:
url: jdbc:mysql://localhost:3306/db
username: user
password: password
driverClassName: com.mysql.cj.jdbc.Driver
jpa:
database: mysql
database-platform: org.hibernate.dialect.MySQL8Dialect
show-sql: true
hibernate:
ddl-auto: create
jackson:
serialization:
write-dates-as-timestamps: false
Db is working and I can connect to it via Idea browser and I can create tables with "user" user. My MySql server config in docker-compose:
db:
image: mysql/mysql-server
restart: always
environment:
MYSQL_DATABASE: 'db'
MYSQL_USER: 'user'
MYSQL_PASSWORD: 'password'
MYSQL_ROOT_PASSWORD: 'password'
ports:
- 3306:3306
expose:
- 3306
I guess my application classes is fine because it works with h2 DB and tables still creating with h2.
I'm using Spring Boot 2.1.6 and latest docker image MySql 8.0.20
Ok, I solved it, section "jpa" needs to be under "spring" section, not under "datasource" section. And it worked with h2 because spring data using ddl-auto: create-drop by default for embedded databases.