2013-02-08 109 views
0

我面臨的一個問題是,我的數據庫連接似乎從jdbc(使用PGCopyOutputStream)中斷到COPY命令的中途。任何想法,爲什麼這可能會發生。我正在寫一個有兩列整數的表格。我在PostgesSQL 9.0.3PostgresSQL PGCopyOutputStream丟失連接

java.io.IOException: Write to copy failed. 
at org.postgresql.copy.PGCopyOutputStream.write(PGCopyOutputStream.java:84) ~[postgresql-9.0-801.jdbc4.jar:na] 
at org.postgresql.copy.PGCopyOutputStream.write(PGCopyOutputStream.java:76) ~[postgresql-9.0-801.jdbc4.jar:na] 
at 
    ... 
    ... 
Caused by: org.postgresql.util.PSQLException: Database connection failed when writing to copy 
at org.postgresql.core.v3.QueryExecutorImpl.writeToCopy(QueryExecutorImpl.java:856) ~[postgresql-9.0-801.jdbc4.jar:na] 
at org.postgresql.core.v3.CopyInImpl.writeToCopy(CopyInImpl.java:53) ~[postgresql-9.0-801.jdbc4.jar:na] 
at org.postgresql.copy.PGCopyOutputStream.writeToCopy(PGCopyOutputStream.java:125) ~[postgresql-9.0-801.jdbc4.jar:na] 
at org.postgresql.copy.PGCopyOutputStream.write(PGCopyOutputStream.java:82) ~[postgresql-9.0-801.jdbc4.jar:na] 
... 10 common frames omitted 
Caused by: java.net.SocketException: Socket closed 
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:116) ~[na:1.7.0_03] 
at java.net.SocketOutputStream.write(SocketOutputStream.java:153) ~[na:1.7.0_03] 
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) ~[na:1.7.0_03] 
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:95) ~[na:1.7.0_03] 
at org.postgresql.core.PGStream.SendChar(PGStream.java:174) ~[postgresql-9.0-801.jdbc4.jar:na] 
at org.postgresql.core.v3.QueryExecutorImpl.writeToCopy(QueryExecutorImpl.java:850) ~[postgresql-9.0-801.jdbc4.jar:na] 
... 13 common frames omitted 

回答

0

這是由於早期的主鍵約束違規,拋出異常並使連接不可用而發生的。