Glassfish 4.1 和 MariaDB 的问题

Glassfish 4.1 and MariaDB troubles

我正在使用 Netbeans 8.2、Glassfish 4.1 和 MariaDB 开发一个企业应用程序,所有这些都是在 Ubuntu 18.04 上完成的。

但是,在与数据库的所有连接建立之后,Glassfish returns 这个异常:

Internal Exception: java.sql.SQLException: Unknown system variable 'OPTION'

如我所见,SET OPTION 命令在 MySQL 5.1 中已弃用,并最终在 MySQL 5.6 中删除。 MariaDB 在他们的 10.0 版本中做了同样的事情。好像Glassfish 4.1还在用这个命令

这让我想到了两个主要解决方案:

有人可以给我一些建议吗?谢谢!

end of the period where Oracle offered a commercially-supported version of Glassfish, thus reducing it to a pure reference implementation role in our experience marked a notable decline in usability and stability of Glassfish, which is a shame. Payara is an externally maintained and up to date version based on the Glassfish sources but with many improvements. Although they already stopped the evolution of GF4 for non-paying customers, they still do offer a downloadable version。我鼓励您对其进行测试,如果您喜欢 Glassfish,您就会喜欢 Payara :)

正确的做法是使用支持现代 SQL 语法的软件版本。即使这不是最简单的解决方案,它很可能会在未来得到回报。


解决此问题的另一种方法是使用 MariaDB MaxScale sit between your application and the database and configure it to translate the SET OPTION SQL to the correct SET form. This can be done with the Regex filter 来应对这种情况。

这是一个小型 SQL 转换服务的 MaxScale 配置,将 SET OPTION 转换为 SET

[maxscale]
threads=auto

[my-database]
type=server
address=hostname-of-my-server
port=3306
protocol=MariaDBBackend

[database-monitor]
type=monitor
module=mariadbmon
servers=my-database
user=<username used to monitor the server>
passwd=<password for the user>
monitor_interval=5000

[replace-option]
type=filter
module=regexfilter
match=SET OPTION
replace=SET

[routing-service]
type=service
router=readconnroute
servers=my-database
user=<username used to monitor the server>
passwd=<password for the user>
filters=replace-option

[routing-listener]
type=listener
service=routing-service
protocol=MariaDBClient
port=3306