I have an inventory management application built with JavaFx and springboot that was originally built to run as standalone using hsqldb. Now I want to upgrade it so that two or more systems can share same database in a LAN environment. When I connect two systems via wifi, I could run the application from the other connected computer but after creating a record, it did not reflect on the other system. Please how do I make this work? Do I need to use mysql instead of hsqldb?
Below is my application.yml file configuration. The lines hashed out are the previous setting for the stand alone version and I have re-defined the hsql settings to use a network path as shown (\PC001\ims_compiled\shared_hsqldb\hsqldb)
Please any assistance ill be appreciated
app:
fixedDelay: 300000
fixedRate: 1200000
localLogin: true
debug: true
hsql:
parameters: hsqldb.lock_file=false;createDatabaseIfNotExist=true;DB_CLOSE_DELAY=-1;shutdown=true;hsqldb.write_delay=false;hsqldb.write_delay_millis=100
log4j:
logger:
org:
hibernate:
transaction: ERROR
springframework:
transaction: ERROR
logging:
config: logback.xml
level:
com:
zaxxer:
hikari:
HikariConfig: ERROR
org:
hibernate:
SQL: ERROR
type:
descriptor:
sql:
BasicBinder: ERROR
mysql-base:
datasource:
DB: ikooba_db
host: 34.244.38.76
jdbc-url: jdbc:mysql://${mysql-base.datasource.host}:${mysql-base.datasource.port}/${mysql-base.datasource.DB}?${mysql-base.datasource.parameters}
parameters: serverTimezone=UTC&useSSL=FALSE&autoReconnect=true&sessionVariables=sql_mode=''
password: 'gsjgsgssshj'
port: 3306
username: sfgsdsfdfs
sentry:
dsn: https://shfs6765676757shsvvs#errors.xxxxxxxx.com/6
enabled: true
stacktrace:
app:
packages: com.ikooba.desktop.ims
spring:
datasource:
hikari:
auto-commit: true
# jdbcUrl: jdbc:hsqldb:hsqldb/userDB;${hsql.parameters}
jdbcUrl: jdbc:hsqldb:\\PC001\ims_compiled\shared_hsqldb\hsqldb/userDB;${hsql.parameters}
password: ''
username: sa
jpa:
hibernate:
ddl-auto: update
use-new-id-generator-mappings: true
properties:
hibernate:
enable_lazy_load_no_trans: true
jdbc:
batch_size: 120
order_inserts: true
search:
default:
directory_provider: filesystem
# indexBase: hsqldb/lucence/indexes
indexBase: \\PC001\ims_compiled\shared_hsqldb\hsqldb/lucence/indexes
indexwriter:
infostream: true
generate_statistics: true
jmx_enabled: true
lucene_version: LATEST
javax:
persistence:
validation:
mode: none
main:
allow-bean-definition-overriding: true
lazy-initialization: true
Setup a HSQLDB server on PC001 and connect to it from different machines.
Chapter 15. http://hsqldb.org/doc/2.0/guide/listeners-chapt.html#lsc_hsql_server
For simplicity, create a server.properties file as described. Inside this file the property setting below should reflect the name, path, and the startup properties of your databse. For example:
server.database.0=file:\\PC001\ims_compiled\shared_hsqldb\hsqldb/userDB;hsqldb.write_delay_millis=100
The other parameters that you used in your hsql.parameters are unnecessary (e.g. hsqldb.lock_file, shutdown). See http://hsqldb.org/doc/2.0/guide/dbproperties-chapt.html for valid properties (but you probably don't need them).
Having a really annoying issue with my Spring Boot API.
So I have a MySQL db and a MongoDB which I connect to. Everything with the Mysql works fine i.e. the settings from the Application.yaml file but not Mongo. It ignores the Database name and creates its own one called "test". Even if I put in a random host and port it still connects locally. Anyone able to spot what i'm doing wrong?
server:
servlet:
contextPath: /api/v1/
port: 8080
spring:
data:
mongo.database: springboot-rest
mongo.host: localhost
mongo.port: 27017
output:
ansi:
enabled: ALWAYS
datasource:
url: jdbc:mysql://localhost:3306/spring_social?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
username: test
password: test
servlet:
multipart:
max-file-size: -1
max-request-size: -1
jpa:
show-sql: true
hibernate:
ddl-auto: update
naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
EDIT worth noting i also tied this way with no luck either:
spring:
data:
mongo:
database: springboot-rest
host: localhost
port: 27017
output:
ansi:
enabled: ALWAYS
datasource:
url: jdbc:mysql://localhost:3306/spring_social?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
username: test
password: test
mongodb should be there instead of mongo
spring:
data:
mongodb:
database: springboot-rest
I am working on a project integrating Hadoop, Hive and accessing it via Spring.
Currently my project works with a default Spring repository: "org.springframework.data.jpa.repository.support.SimpleJpaRepository#757b7c0a" but I would want to work with a repository able to understand HIVE queries.
For example, inserting a user into a HIVE database.
Actually I have a connection to HIVE in my project but everything is chaos and nothing works and I believe it is because the repository I am using is not the correct one.
So my question is ... how, where and what values to insert in order to change that repository for a Hive-friendly one ?
I have this in my application.yml:
spring:
profiles:
include: swagger, no-liquibase
devtools:
restart:
enabled: true
livereload:
enabled: false # we use gulp + BrowserSync for livereload
datasource:
type: org.springframework.jdbc.datasource.DriverManagerDataSource
url: jdbc:hive2://localhost:10000/default;DB_CLOSE_DELAY=0
username: catalin
password:
default-auto-commit: true
jpa:
show-sql: true
properties:
hibernate:
format_sql: true
mail:
host: localhost
port: 25
username:
password:
thymeleaf:
cache: false
liquibase:
contexts: hive
Thank you.
I have multimodule maven project in which I have one common part which I want to share between applications.
In common module I'm defining the configuration for liquibase and db connection. For this I have 2 profiles common-prod and common-dev located in application.yaml.
spring:
profiles: common-prod
# POSTGRE
datasource:
url: ${DATABASE_URL:jdbc:postgresql://localhost:5432/dbname}
driver-class-name: org.postgresql.Driver
username: pguser
password: pguser
jpa:
database-platform: org.hibernate.dialect.PostgreSQLDialect
hibernate:
ddl-auto: none
properties:
hibernate.default_schema: public
#LIQUIBASE
liquibase:
enabled: true
change-log: /db/changelog/db-changelog-master.xml
drop-first: false
---
spring:
profiles: common-dev
# POSTGRE
datasource:
url: ${DATABASE_URL:jdbc:postgresql://localhost:5432/dbname-dev}
username: pguserdev
password: pguserdev
#LIQUIBASE
liquibase:
enabled: true
drop-first: true
now in web application I want to define some additional properties. But when I include them in application.yaml (in web module) I think it overrides the application.yaml from common module.
So I need to
rename the application.yaml from common to something like application-common.yaml
rename the application.yaml in application to something like application-web.yaml
if I rename the common module's yaml file am I able to reference the profiles from within this file? eg something like -Dspring.profiles.active=common-common-prod or I need to separate this profiles to separate yaml files?
If I rename web modules config file to application-web.yaml I must allways include the web profile. I can live with that, but it would be simpler to include the profiles in application.yaml and don't care about command line arguments.
I've got a working Spring Boot Application that connects to a Postgres database. I've got the project set up with an application.properties file, but would like to make the switch over to an application.yml file. However when I make the switch, my application errors out while attempting to connect to the db.
Original applications.properties file:
spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.database.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/mydb
spring.datasource.username=foo
spring.datasource.password=bar
And Here's what I've got so far in the application.yml file:
spring.jpa:
database: POSTGRESQL
hibernate.ddl-auto: create-drop
show-sql: true
spring.datasource:
platform: postgres
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/mydb
username: foo
password: bar
Am I missing something in the translation between file types?
You need to treat each . character in property names as levels in the yaml file:
spring:
jpa:
database: POSTGRESQL
show-sql: true
hibernate:
ddl-auto: create-drop
datasource:
platform: postgres
url: jdbc:postgresql://localhost:5432/mydb
username: foo
password: bar
driverClassName: org.postgresql.Driver
EDIT: edits have been suggested, thanks for that. The driverClassName property actually should be under spring.datasource. However, the purpose of this answer was to show how a properties file is converted into yaml format. So I have changed the driverClassName property to be at the right path, that is not part of the transformation from properties to yaml.
Please upvote the other answer (Z0lt#n's answer)
But pasting here for future readers... a sql server version.
spring:
jpa:
show-sql: true
hibernate:
ddl-auto: update
properties:
hibernate.jdbc.batch_size: 20
hibernate.cache.use_query_cache: false
hibernate.cache.use_second_level_cache: false
hibernate.cache.use_structured_entries: false
hibernate.cache.use_minimal_puts: false
datasource:
#SPRING_DATASOURCE_URL environment variable will be something like -> jdbc:sqlserver://MySqlServer\\MyInstance:1433;DatabaseName=MyDbName;
url: ${SPRING_DATASOURCE_URL}
username: ${SPRING_DATASOURCE_USERNAME}
password: ${SPRING_DATASOURCE_PASSWORD}
driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
and maven entry
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.0.0.jre8</version>
</dependency>
APPEND
This seems to be the "standard" name for the driverClassName.
SPRING_DATASOURCE_DRIVER-CLASS-NAME
And of course, in my example, you would use the value of:
com.microsoft.sqlserver.jdbc.SQLServerDriver
NOW, some spring, springboot, environment variable voodoo alert.
Sometimes, when specifying the environment variable...for some command lines items, I would have to change the hyphens and make them underscores.
(aka, "SPRING_DATASOURCE_DRIVER-CLASS-NAME" vs "SPRING_DATASOURCE_DRIVER_CLASS_NAME"
below the -e generically represents "passing environment variable values via the command line"
MyCommandLineProgram.exe -e SPRING_DATASOURCE_URL="jdbc:sqlserver://myServerName:1433;DatabaseName=MyDB;" -e SPRING_DATASOURCE_USERNAME="myUserName" -e SPRING_DATASOURCE_PASSWORD="myPassword" -e SPRING_DATASOURCE_DRIVER_CLASS_NAME="com.microsoft.sqlserver.jdbc.SQLServerDriver"
There's some voodoo for you.
Those interested in the logging (logback.xml) issue, maybe want to find my answer here as well:
Spring Boot Logback DB Appender Properties
application.yml file for postgresql
Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring:
datasource:
driver-class-name: org.postgresql.Driver
username: postgres
password: root
url: jdbc:postgresql://localhost/postgres
platform: postgres
initialization-mode: always
continue-on-error: true
jpa:
show-sql: true
generate-ddl: true
hibernate:
ddl-auto: create
database: postgresql
server:
port: 1111
spring:
application:
name: client-one
datasource:
password: postgres
url: jdbc:postgresql://localhost:5432/postgres?currentSchema=education
username: postgres
jpa:
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
show-sql: true