如何使用 SpringBoot 桌面应用程序设置 JavaFX 以在 LAN 上共享数据库
我有一个使用 JavaFx 和 springboot 构建的库存管理应用程序,最初构建为使用 hsqldb 作为独立运行。现在我想升级它,以便两个或多个系统可以在局域网环境中共享同一个数据库。当我通过 wifi 连接两个系统时,我可以从另一台连接的计算机运行该应用程序,但创建记录后,它没有反映在另一个系统上。请问我该如何进行这项工作?我需要使用 mysql 而不是 hsqldb 吗? 以下是我的 application.yml 文件配置。散列出来的行是独立版本的先前设置,我已经重新定义了 hsql 设置以使用所示的网络路径(\PC001\ims_compiled\shared_hsqldb\hsqldb)
请提供任何帮助,不胜感激
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://[email protected]/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
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://[email protected]/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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 PC001 上设置 HSQLDB 服务器并从不同的计算机连接到它。
第 15 章 http://hsqldb.org/doc/2.0/guide /listeners-chapt.html#lsc_hsql_server
为简单起见,请按所述创建一个
server.properties 文件
。在此文件中,下面的属性设置应反映数据库的名称、路径和启动属性。例如:您在
hsql.parameters
中使用的其他参数是不必要的(例如 hsqldb.lock_file、shutdown)。请参阅http://hsqldb.org/doc/2.0/guide/dbproperties-chapt .html 以获得有效属性(但您可能不需要它们)。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: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).