Mock database driver

后端 未结 7 1349
臣服心动
臣服心动 2021-01-17 12:34

Is there some kind of JDBC driver which simply ignores database calls?

For the development I am migrating an application to a virtual machine. Here I want to work on

相关标签:
7条回答
  • 2021-01-17 13:30

    There are some "void" JDBC drivers as part of Mocking framewroks, for example MockDriver from Mockrunner.

    But using it requires some coding.

    That's because when Java application connects to a database it provides a JDBC URL in form jdbc:mysql://localhost. The system is searching which driver is registered in it to handle this kind of URL and chooses the right driver. The info about which URL type driver supports is contained in the driver itself, and it's impossible for a mock driver to hold all known URL types in it - there's no such thing as wildcarding there and any list would not be full.

    So, if you're able to call JDBCMockObjectFactory.registerMockDriver() in the application before it connects to the database - it will do the job. If not - I don't think it's possible. However, slight modification of the driver code would do it... but again - coding is required.

    0 讨论(0)
提交回复
热议问题