SoapUI + sqlite-jdbc = ClassNotFoundException

发布于 2024-12-25 09:30:57 字数 617 浏览 3 评论 0原文

我想在 SoapUI Groovy 脚本中使用 SQLite 数据库。

我已将库 sqlitejdbc-v056.jar 复制到 SoapUI 的 /bin/ext 目录(理论上是 SoapUI 类路径),并且像这样使用它:

import groovy.sql.Sql
def sql = Sql.newInstance( "jdbc:sqlite:/path_to_database", "org.sqlite.JDBC" )

当我运行 MockService 时,我得到以下异常:

java.sql.SQLException: No suitable driver found for jdbc:sqlite:/path_to_database

当我使用 Class.forName("org.sqlite.JDBC") 时,我得到另一个异常:

java.lang.ClassNotFOundException: org.sqlite.JDBC

两种方法在 groovyConsole 中都工作正常。

我怎样才能让它们在 SoapUI 中工作?

I'd like to use SQLite database in SoapUI Groovy script.

I have copied the library sqlitejdbc-v056.jar into SoapUI's /bin/ext directory (theoretically SoapUI classpath) and I use it like this:

import groovy.sql.Sql
def sql = Sql.newInstance( "jdbc:sqlite:/path_to_database", "org.sqlite.JDBC" )

When I run the MockService i get the following exception:

java.sql.SQLException: No suitable driver found for jdbc:sqlite:/path_to_database

When I use Class.forName("org.sqlite.JDBC") i get another exception:

java.lang.ClassNotFOundException: org.sqlite.JDBC

Both methods work fine in groovyConsole.

How can I make them work in SoapUI?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒绊 2025-01-01 09:30:57

好的,我找到了答案。
除了将库 .jar 文件复制到soapui/bin/ext 之外,您还需要

com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("org.sqlite.JDBC")

在使用 groovy.sql.Sql 之前在代码中添加:

Ok, I found the answer.
Apart from copying the library .jar file to soapui/bin/ext you need to add:

com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("org.sqlite.JDBC")

in your code before using groovy.sql.Sql.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文