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?
Related
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
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
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)
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.
When I run my rails server locally with a local mysql server, my endpoints work fine and things are being inserted and updated to the mysql database and everything is just beautiful.
When I deploy to AWS OpsWorks, however, the application get's deployed and I'm able to see what's in the /public folder, but all my actions don't work and I'm not quite sure how to debug this.
When I check the log, see that bundle install gets called, and even then following...
[2014-07-13T14:37:34+00:00] INFO: No database adapter specified for bgs_api, guessing
[2014-07-13T14:37:35+00:00] INFO: Looks like bgs_api uses mysql2 in its Gemfile
.. but nothing regarding the actual creation of the tables or execution of the migrations.
About my instance and app...
I have one EC2 instance that has both the Rails and MySQL layers on it.
I'm using a database.yml file, but I'm not sure if this means that I can ignore putting in the custom JSON when deploying the application. Which is what I'm currently doing.
Here is my database.yml file
development:
adapter: mysql2
encoding: utf8
reconnect: true
database: xyz #name for local database defined by me
username: abc #username for local database user defined by me
password: 123 #password for local database user defined by me
pool: 5
host: localhost
production:
adapter: mysql2
encoding: utf8
reconnect: true
database: xyz #name for opsworks database defined by me
username: root #username for opsworks database defined by opsworks
password: abc #password for opsworks database defined by opsworks
pool: 5
host: localhost
One particular thing I'm not sure about is the production host value... I imagine it would be localhost because this get's run on the ec2 insatnce.
Any help or direction for debugging would be of great help. Thank you!
You need to send in the database details via custom JSON. This is because the APP doesn't have the connection details automatically from the configurations. Even if you do add it into the codebase, it'll get over written by the recipes.
{
"deploy":{
"app_name":{
"database":{
"password":"",
"adapter":"mysql2",
"username":"",
"database":"",
"host":"localhost"
}
}
}
}
You need to run normal task that does create your database etc. This is something you should do to seperately as part of installing the app. A good option would be to use the deployment hooks : opsworks hooks