使用 org.apache.ddlutils.DdlUtilsException 时出现问题
我正在尝试使用 org.apache.ddlutils 包来读取数据库元数据。 我编写了以下方法:
public static void readMetaData(DataSource dataSource) throws DdlUtilsException{
final Platform platform = PlatformFactory.createNewPlatformInstance(dataSource);
}
但是语句抛出DdlUtilsException给出了以下错误:
不能抛出DdlUtilsException类型的异常;异常类型必须是 Throwable 的子类
我根本不明白这个错误背后的原因,因为 API http://db.apache.org/ddlutils/api/org/apache/ddlutils/DdlUtilsException.html 明确指出以下内容:
java.lang.Object
extended by java.lang.Throwable
extended by java.lang.Exception
extended by java.lang.RuntimeException
extended by org.apache.commons.lang.exception.NestableRuntimeException
extended by org.apache.ddlutils.DdlUtilsException
请提出建议。
I'm trying to use the org.apache.ddlutils package for reading database metadata.
I've written the following method:
public static void readMetaData(DataSource dataSource) throws DdlUtilsException{
final Platform platform = PlatformFactory.createNewPlatformInstance(dataSource);
}
But the statement throws DdlUtilsException gives the following error:
No exception of type DdlUtilsException can be thrown; an exception type must be a subclass of Throwable
I simply do not understand the reason behind this error because the API at http://db.apache.org/ddlutils/api/org/apache/ddlutils/DdlUtilsException.html clearly states the following:
java.lang.Object
extended by java.lang.Throwable
extended by java.lang.Exception
extended by java.lang.RuntimeException
extended by org.apache.commons.lang.exception.NestableRuntimeException
extended by org.apache.ddlutils.DdlUtilsException
Please advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的猜测是,您在某处有另一个名为
DdlUtilsException
的类 - 可能在顶级包中,因为编译器没有提及完整的包名称。如果您使用 Eclipse 或类似的工具,请尝试导航到类声明。编辑:好的,从您的评论来看,您没有包括各种依赖项。确保您已下载 DdlUtils-1.0-bin.zip,并且依赖项均位于 lib 目录中。我并不清楚您是否需要全部它们,但您不妨先使用它们,然后删除不需要的内容。
My guess is that you've got another class called
DdlUtilsException
somewhere - possibly in the top-level package, given that the compiler isn't mentioning a full package name. If you're using Eclipse or something similar, try to navigate to the class declaration.EDIT: Okay, judging by your comment, you aren't including the various dependencies. Make sure you've downloaded DdlUtils-1.0-bin.zip, and the dependencies are all in the lib directory. It's not immediately clear to me whether you need all of them, but you might as well use them all to start with, and then remove what you don't need.
看起来其他类“org.apache.commons.lang.exception.NestableRuntimeException”位于commons-lang中。下载并添加该 jar,它应该可以工作。检查 DDL Utils 的文档,看看它还依赖什么。
It looks like that other class 'org.apache.commons.lang.exception.NestableRuntimeException' is located in commons-lang. Download and add that jar and it should work. Check the docs for DDL Utils and see what else it depends on.