问题描述
是否有某种JDBC驱动程序只是忽略数据库调用?
Is there some kind of JDBC driver which simply ignores database calls?
对于开发我正在将应用程序迁移到虚拟机。在这里,我只想处理GUI部分。但是应用程序向数据库发出了几个请求,这些请求甚至不会让应用程序启动。我不想在此时更改应用程序代码,因为数据库几乎是耦合的。
For the development I am migrating an application to a virtual machine. Here I want to work on the GUI part only. But the application makes several requests to a database which doesn't let the application even start. I don't want to change the application code at this time since the database is pretty much coupled.
所以我认为可能有一个JDBC驱动程序只返回空查询结果。
So I was thinking there could be a JDBC driver which just returns empty results for queries.
推荐答案
我决定编写一个自己的简单模拟驱动程序。这非常直接,做了我想要的。我可以通过配置文件切换应用程序的数据库驱动程序,这样我就可以让应用程序以简单的方式使用我的驱动程序。
I decided to write an own simple mock driver. This was pretty much straight forward and did what I want. I can switch the database driver of the application by a configuration file so I could let the application use my driver on a simple way.
然后我扩展了驱动程序以返回数据它从CSV文件解析。我在谷歌代码上发布了代码,也许其他人可以使用它:
Then I extended the driver to return data which it parses from CSV files. I published the code on google code maybe someone else can get use of it: dummyjdbc
这篇关于模拟数据库驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!