我正在构建一个 Java + Spring Web 客户端,该客户端接收 XML 并将其解组为自动生成的类,基于我正在联系的服务提供的模式。
自动生成的代码包含一个返回Element对象的 getter 。为了处理这个对象,我将它转换为ElementNSImpl.
public Element getThing() {
return thing;
}
Run Code Online (Sandbox Code Playgroud)
ElementNSImpl element = (ElementNSImpl) obj.getThing();
element.doSomething();
Run Code Online (Sandbox Code Playgroud)
但是,我有两个可用的类资源ElementNSImpl:
com.sun.org.apache.xerces.internal.dom.ElementNSImpl
Run Code Online (Sandbox Code Playgroud)
和
org.apache.xerces.dom.ElementNSImpl
Run Code Online (Sandbox Code Playgroud)
我也有两个环境(测试和生产)。测试机运行 CentOS Linux 7 和 OpenJDK 1.8.0_161。生产机器运行 SUSE Linux Enterprise Server 11 SP4 和 Oracle JDK。
我遇到的问题是,当我在测试环境中运行代码时,出现以下异常:
com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to org.apache.xerces.dom.ElementNSImpl
Run Code Online (Sandbox Code Playgroud)
因此,我将我的课程修改为 importcom.sun.org.apache.xerces.internal.dom.ElementNSImpl而不是org.apache.xerces.dom.ElementNSImplvoilà,它开始工作了!然后我将相同的 JAR 上传到生产环境,出现以下异常:
org.apache.xerces.dom.ElementNSImpl cannot be cast to com.sun.org.apache.xerces.internal.dom.ElementNSImpl
Run Code Online (Sandbox Code Playgroud)
似乎每个程序都以不同的方式解组 XML,甚至认为两个代码完全相同。
我还必须告知,正在联系的测试服务器和生产服务器并不相同。他们应该是相同的并且行为方式相同(根据他们的支持团队)。只有不同的数据库。
这个问题可能与我的申请有关吗?或者它可能与我从服务器获取的文件有关?它可能是 OpenJDK 的东西吗?
我需要通过Java应用程序将一些数据备份为INSERT语句.我在SQL Developer中找到的最直接的方法是运行select with /*insert*/.
例如:
SELECT /*insert*/ * FROM table_name WHERE col_a = 1 AND col_b = 2;
Run Code Online (Sandbox Code Playgroud)
如果我在SQL Developer中将此查询作为脚本(F5)运行,我会得到它的结果,就像我需要的那样.问题是我找不到从Java应用程序中将此查询作为脚本运行并将DB文本输出返回到程序的方法.我想以字符串形式接收脚本输出,然后将其打印到文件中.
以往我跑我所有的查询JdbcTemplate和PreparedStatementCreator,但在所有的方法JdbcTemplate似乎需要某种排映到查询内容到一个对象的属性转移.