postgre数据库连接问题!想要多少分就给多少!

jiminer 2004-08-02 11:25:33
奇怪的问题:

以下是我的代码片段:

try{
oStmt = oConn.createStatement();
String sSQL = "insert into test_table values('" + sContent + "')";
oStmt.executeUpdate(sSQL);
} catch(Exception e){
}finally{
if(oStmt != null){
try{
oStmt.close();
}catch(Exception e){
}
oStmt = null;
}
if(oConn != null){
try{
oConn.close();
}catch(Exception e){
}
oConn = null;
}
}
}

Connection 是从Tomcat的连接池中取得的。
sContent 是从网关接收的字符串,是一堆乱码,值为“GHOG^@:?UN9”。在执行SQL语句的时候抛出以下异常:
java.sql.SQLException: ERROR: parser: unterminated quoted string at or near "'GHOG" at character ……
在第二个数据库操作的时候就出现以下异常:
The backend has broken the connection. Possibly the action you have attempted has caused it to close.
在以后的数据库操作就出现以下异常:
An I/O error has occured while flushing the output - Exception: java.net.SocketException: Broken pipe
Stack Trace:

java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:69)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:127)
at org.postgresql.PG_Stream.flush(PG_Stream.java:355)
at org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:139)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:63)
at org.postgresql.Connection.ExecSQL(Connection.java:451)
at org.postgresql.Connection.ExecSQL(Connection.java:434)
at org.postgresql.jdbc1.Statement.execute(Statement.java:111)
at org.postgresql.jdbc1.Statement.executeQuery(Statement.java:49)
.
.
.
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:536)
End of Stack Trace

只要出现了第三个异常,所有对数据库的操作都抛出这个异常,直到重启Tomcat。

请教各位高手,这是什么原因?如何解决?
万分感谢!


...全文
133 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

956

社区成员

发帖
与我相关
我的任务
社区描述
PostgreSQL相关内容讨论
sql数据库数据库架构 技术论坛(原bbs)
社区管理员
  • PostgreSQL社区
  • yang_z_1
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧