NutzCN Logo
问答 insert 插入 PG如何消除返回值的冲突
发布于 2068天前 作者 澎小湃Fight 3954 次浏览 复制 上一个帖子 下一个帖子
标签:

2019-03-19 15:41:21,768 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - INSERT INTO webmaster_basetable_crc_error(data_time,device_name,network_name,device_ip,crc_code) VALUES(?,?,?,?,?)
| 1 | 2 | 3 | 4 | 5 |
|---------------------|---------------------------------|-----------------------|-------------|------|
| 2019-03-19 14:00:00 | New-JLCC-PA-CMNET-RT06-NE5KE-PY | NULL0 | 111.26.25.8 | NULL |
| 2019-03-19 14:00:00 | New-JLCC-PA-CMNET-RT06-NE5KE-PY | LoopBack0 | 111.26.25.8 | NULL |
| 2019-03-19 14:00:00 | New-JLCC-PA-CMNET-RT06-NE5KE-PY | InLoopBack0 | 111.26.25.8 | NULL |
| 2019-03-19 14:00:00 | New-JLCC-PA-CMNET-RT06-NE5KE-PY | GigabitEthernet3/1/9 | 111.26.25.8 | 0.0 |
| 2019-03-19 14:00:00 | New-JLCC-PA-CMNET-RT06-NE5KE-PY | GigabitEthernet3/1/8 | 111.26.25.8 | 0.0 |
| 2019-03-19 14:00:00 | New-JLCC-PA-CMNET-RT06-NE5KE-PY | GigabitEthernet3/1/7 | 111.26.25.8 | 0.0 |
| 2019-03-19 14:00:00 | New-JLCC-PA-CMNET-RT06-NE5KE-PY | GigabitEthernet3/1/6 | 111.26.25.8 | 0.0 |
| 2019-03-19 14:00:00 | New-JLCC-PA-CMNET-RT06-NE5KE-PY | GigabitEthernet3/1/5 | 111.26.25.8 | 0.0 |
| 2019-03-19 14:00:00 | New-JLCC-PA-CMNET-RT06-NE5KE-PY | GigabitEthernet3/1/4 | 111.26.25.8 | 0.0 |
| 2019-03-19 14:00:00 | New-JLCC-PA-CMNET-RT06-NE5KE-PY | GigabitEthernet3/1/3 | 111.26.25.8 | 0.0 |
-- Only display first 10 lines , don't show the remaining record(count=39)
For example:> "INSERT INTO webmaster_basetable_crc_error(data_time,device_name,network_name,device_ip,crc_code) VALUES('2019-03-19 14:00:00','New-JLCC-PA-CMNET-RT06-NE5KE-PY','NULL0','111.26.25.8',NULL) "




for (int j = 0; j < array.size(); j++) { port = new StringBuffer(Util .reBuildJSONObject(array.get(j).toString()).get("key") .toString()); if (Util.reBuildJSONObject( Util.reBuildJSONObject(array.get(j).toString()) .get("1").toString()).size() == 0) { sql = "insert into " + TABLE + " (data_time,device_name,network_name,device_ip)" + " values('" + realTime + "','" + device_name + "','" + port + "','" + device_ip + "')"; cc = new Crc_Code(); cc.setData_time(realTime); cc.setDevice_name(device_name); cc.setNetwork_name(port.toString()); cc.setDevice_ip(device_ip); } else { crc_code = new StringBuffer(Util .reBuildJSONObject( Util.reBuildJSONObject( array.get(j).toString()).get("1") .toString()).get("value") .toString()); sql = "insert into " + TABLE + " (data_time,device_name,network_name,device_ip,crc_code)" + " values('" + realTime + "','" + device_name + "','" + port + "','" + device_ip + "'," + crc_code + ")"; cc = new Crc_Code(); cc.setData_time(realTime); cc.setDevice_name(device_name); cc.setNetwork_name(port.toString()); cc.setDevice_ip(device_ip); cc.setCrc_code(Double.parseDouble(crc_code.toString())); } try { allList.add(cc); } catch (Exception e) { e.printStackTrace(); System.err.println(sql); } } daoZC.fastInsert(allList);
4 回复

没报错信息呀

没有PG版本呀, 没有nutz版本呀

nutz 1.65
gp 5.多 对应的pg 是8.多。。。

java.sql.BatchUpdateException: Batch entry 0 INSERT INTO webmaster_basetable_crc_error(data_time,device_name,network_name,device_ip,crc_code) VALUES('2019-03-19 14:00:00','JLBAC-BAS06-7750-SR12-GYY','xingjianoltc300','111.26.125.4',1.0) 
RETURNING * was aborted: ERROR: The RETURNING clause of the INSERT statement is not supported in this version of Greenplum Database.  Call getNextException to see other errors in the batch.
	at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:148)
	at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:819)
	at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1556)
	at com.alibaba.druid.filter.FilterChainImpl.statement_executeBatch(FilterChainImpl.java:2708)
	at com.alibaba.druid.filter.FilterAdapter.statement_executeBatch(FilterAdapter.java:2496)
	at com.alibaba.druid.filter.FilterEventAdapter.statement_executeBatch(FilterEventAdapter.java:279)
	at com.alibaba.druid.filter.FilterChainImpl.statement_executeBatch(FilterChainImpl.java:2706)
	at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.executeBatch(StatementProxyImpl.java:202)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeBatch(DruidPooledPreparedStatement.java:566)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:322)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:159)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithTransaction(NutDaoRunner.java:105)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:89)
	at org.nutz.dao.impl.sql.run.NutDaoRunner$1.run(NutDaoRunner.java:75)
	at org.nutz.trans.Trans.exec(Trans.java:174)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:73)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:252)
	at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:55)
	at org.nutz.dao.impl.NutDao.fastInsert(NutDao.java:193)
	at com.yd.mds.root.ErrorCodeRoot.reBuildDSLJson(ErrorCodeRoot.java:219)
	at com.yd.mds.root.ErrorCodeRoot.getErrorDevice(ErrorCodeRoot.java:96)
	at com.yd.mds.MainModule$1.run(MainModule.java:56)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.postgresql.util.PSQLException: ERROR: The RETURNING clause of the INSERT statement is not supported in this version of Greenplum Database.
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2427)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2169)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
	at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:816)
	... 33 more

PostgreSQL 8.3.23 (Greenplum Database 5.9.0 build commit:214d9aef83b1aeb1ba7d2c2f9bf1c50ca6aa7c1d) on x86_64-pc-linux-gnu, compiled by GCC gcc (GCC) 6.2.0, 64-bit compiled on Jun 15 2018 00:40:01

已解决,感谢大佬,最终删除实体类中 @ID的自增id字段,可以正常插入了。

添加回复
请先登陆
回到顶部