Java通用JDBC SQL查询策略,用于使用HSQLDB进行单元测试和使用MySQL进行运行时 [英] Java common JDBC SQL Query strategy for Unit Test using HSQLDB and runtime using MySQL

查看:111
本文介绍了Java通用JDBC SQL查询策略,用于使用HSQLDB进行单元测试和使用MySQL进行运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Java Vert.x 3应用程序.我使用HSQLDB与内存数据库进行测试,并使用MySQL 8.0.20对运行时进行测试.部署vertx verticle时,它将初始化db和表.由于这是通用代码,并且HSQLDB和MySQL之间存在不同的SQL语法,而且更荒谬,因此HSQLDB将所有属性名称都大写,并且我必须对属性加双引号以使用小写字母.我想知道如何实现这一目标.这是我的问题:

I am developing Java Vert.x 3 application. I use HSQLDB for testing with in-memory DB and MySQL 8.0.20 for runtime. When the vertx verticle is deployed, it initializes the db and tables. Since this is a common code and there are differing SQL syntax between HSQLDB and MySQL and more ridiculously, the HSQLDB capitalizes all the property names and I have to double-quote the properties to use lower-case. I wonder how to achieve this. Here are my questions:

(1)HSQLDB使用"IDENTITY"用于创建内存数据库表的关键字.这导致MySQL DB中的运行时错误为"IDENTITY".无效的关键字.这构成了我现在面临的挑战.

(1) HSQLDB uses "IDENTITY" keyword for creating the in-memory database table. This results in runtime error in MySQL DB as "IDENTITY" is not valid keyword. This poses a challenge that I am facing now.

(2)如果无法使用同时满足MySQL和HSQLDB的通用SQL语法,则基于Java应用程序运行时配置文件拆分此通用执行路径的最佳方法是什么,因为此数据库初始化是在start垂直功能是应用程序的核心吗?

(2) If it is not possible to have a common SQL syntax which satisfies both MySQL and HSQLDB, what's the best approach to split this common execution path based on the java application runtime profile since this DB initialization is done in the start function of the verticle which is the core of the application?

任何建议和见识都受到赞赏.

Any advice and insight is appreciated.

推荐答案

解决方案:放弃HSQLDB并将H2与database_to_upper=false选项一起使用.

Solution: Ditch HSQLDB and use H2 with database_to_upper=false option.

这篇关于Java通用JDBC SQL查询策略,用于使用HSQLDB进行单元测试和使用MySQL进行运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆