SQL Update 挂起 Java 程序
我正在编写一个 Java/Perl 组合程序,用于将 XML 文件解析到 Oracle SQL 数据库中。数据库中有两个表 - 一个保存 XML 文件中的数据,另一个保存有关文件本身的信息(文件名、创建时间等)。基本上,当出现新的 XML 文件时,Java 程序会检查它是否已被解析或部分解析。如果有,它会使用 UPDATE FILESTATUS SET STATUS='bad' WHERE ID=?< 将该文件 ID 的 filestatus 表中的
STATUS
列从“good”更改为“bad” /代码>。但是,当我运行它时,它会卡住这样做。有什么想法为什么会发生这种情况吗?没有出现错误消息,它只是挂起。代码如下。
static void markDataBad(String docID)
{
try
{
String update = "UPDATE FILESTATUS SET STATUS='bad' WHERE ID=?";
PreparedStatement updateStatus = Main.con.prepareStatement(update);
updateStatus.setString(1, docID);
updateStatus.execute();
}
catch (Exception ex) {ex.printStackTrace();}
}
我已经尝试将 updateStatus.execute()
更改为 updateStatus.executeQuery()
和 updateStatus.executeUpdate()
,但似乎没有任何效果改变了。
提前致谢!
I'm writing a combination Java/Perl program that parses XML files into an Oracle SQL database. There are two tables in the database - one that holds the data from the XML files and another that holds information about the files themselves (file name, creation time, etc.). Basically, when a new XML file comes along, the Java program checks to see if it has already been parsed, or partially parsed. If it has, it changes the STATUS
column in the filestatus table from 'good' to 'bad' for that file ID, using UPDATE FILESTATUS SET STATUS='bad' WHERE ID=?
. However, when I run it, it gets stuck doing this. Any ideas why this could happen? No error messages are occurring, it just hangs. The code is below.
static void markDataBad(String docID)
{
try
{
String update = "UPDATE FILESTATUS SET STATUS='bad' WHERE ID=?";
PreparedStatement updateStatus = Main.con.prepareStatement(update);
updateStatus.setString(1, docID);
updateStatus.execute();
}
catch (Exception ex) {ex.printStackTrace();}
}
I've already tried changing updateStatus.execute()
to updateStatus.executeQuery()
and updateStatus.executeUpdate()
, but nothing seems to have changed.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否在其他地方对该表进行了未提交的更改?我今天遇到了这个问题,因为我在 SQL*Developer 中对表进行了一些更改,并且在我提交之前一直持有表上的锁。
Do you have uncommited changes to that table somewhere else? I had this problem today because I'd made some changes to the table in SQL*Developer, and that was holding onto a lock on the table until I committed it.
您的用户有该表的权限吗?
您是否在表上锁定或丢失提交之前发出过?
你能在 shell 中运行查询吗?
Does your user have permission for that table?
Have you issued before a lock on the table or a missing commit?
Can you run the query in shell?