小编Vis*_*hnu的帖子

将ResultSet中的Row插入到不同的数据库-Jdbc中

使用jdbc我正在一个服务器上执行查询并获取resultSet1.现在,我根据resultSet1在另一台服务器上创建了一个表(服务器号:2).在此之后,我想将ResultSet1直接插入到服务器2中创建的表中.做这个的最好方式是什么 ?就像我一样,是否有任何resultSet.insertRowInto()类函数(不使用确切表数据的通用答案)?

Connection connection1, connection2;
connection1 = connectDB("192.168.40.1","db1","root","");
connection2 = connectDB("192.168.45.1","db2","root","");

//I have table1 in db1 and db2 and their structure is same

stmt = connection1.createStatement();
ResultSet = stmt.executeQuery("Select * from table1");
Run Code Online (Sandbox Code Playgroud)

现在我还要求将resultSet复制到db2中的table1.

java jdbc

9
推荐指数
1
解决办法
1万
查看次数

将 log4j2 与 junit 一起使用时出现 ParserConfigurationException

我使用的是junit 4.10和log4j2 2.10版本

我收到以下异常,我无法弄清楚

ERROR StatusLogger Error parsing /scratch/log4j.xml
javax.xml.parsers.ParserConfigurationException
    at oracle.xml.jaxp.JXDocumentBuilderFactory.setFeature(JXDocumentBuilderFactory.java:374)
    at org.apache.logging.log4j.core.config.xml.XmlConfiguration.setFeature(XmlConfiguration.java:213)
    at org.apache.logging.log4j.core.config.xml.XmlConfiguration.disableDtdProcessing(XmlConfiguration.java:205)
    at org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:194)
    at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:92)
    at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)
    at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:417)
    at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:346)
    at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:260)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:613)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:634)
    at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:229)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:243)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
    at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:648)
    at oracle.oki.service.SampleBaseTest.<clinit>(SampleBaseTest.java:53)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:337)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:931)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:785)
    ERROR StatusLogger No logging configuration
Run Code Online (Sandbox Code Playgroud)

我能够在独立程序中使用相同的配置文件,并且一切顺利。

java logging jvm log4j log4j2

8
推荐指数
1
解决办法
1810
查看次数

将Big Integer值转换为8位字节(2s补码大端)序列,这是Java中8的倍数

如何在Java 中将大整数转换为以下字节数组形式:

大整数被编码为8位字节的序列,以二进制补码表示,传输大端.如果序列的长度不是8个字节的倍数,则应使用最小数量的前导符号扩展字节填充大整数,以使长度为8个字节的倍数.

这与KMIP协议第9.1.1.4节项目值一致

java biginteger data-conversion java-8 kmip

6
推荐指数
1
解决办法
109
查看次数

从类型'int'分配类型'memstruct'时不兼容的类型

我在C中为以下行获取错误"从类型'int'中分配类型'memstruct'时出现的不兼容类型:

result1 = getValueFromBind(interpret(t->ptr1));.
Run Code Online (Sandbox Code Playgroud)

result1和function的声明如下:

memstruct result1;
memstruct getValueFromBind(memstruct bind);
Run Code Online (Sandbox Code Playgroud)

此外,memstruct函数定义如下:typedef union Constant {int intval; char*strval; }不变; typedef struct memstruct {int type; 恒定价值; } memstruct;

编辑:getValueFromBind函数在简单检查后返回bind或NULL.解释返回memstruct.此外,错误显示在C中的分配.

以下是极简主义的例子(@gsamaras):http://ideone.com/Rb8ZCd

当dsh回答它时,解决了程序中的错误

c struct compiler-errors

0
推荐指数
1
解决办法
1131
查看次数

标签 统计

java ×3

biginteger ×1

c ×1

compiler-errors ×1

data-conversion ×1

java-8 ×1

jdbc ×1

jvm ×1

kmip ×1

log4j ×1

log4j2 ×1

logging ×1

struct ×1