Redian新闻
>
请教一个关于JDBC的问题,实在太烦了!
avatar
请教一个关于JDBC的问题,实在太烦了!# Java - 爪哇娇娃
w*y
1
我想用JDBC往数据库里插入几条记录,但每次执行到executeUpdate(...),程序就死住了
。用catch也找不到error,用PreparedStatement也是同样的问题,用新的Connection,St
atement也不行,反正我能想到的都试过了。----有人说是内存溢出,但是只插入一条记
录,怎么会溢出呢?
请问各位有没有遇到类似这样的问题,如何解决?BTW,我用的是Oracle, 以前从来没问
题的。
avatar
xt
2


。用catch也找不到error,用PreparedStatement也是同样的问题,用新的Connection,St


Did you check your autocommit setting on your java.sql.Connection? If it is
false
you need to explicitly commit or your DB tables will be locked.

【在 w*********y 的大作中提到】
: 我想用JDBC往数据库里插入几条记录,但每次执行到executeUpdate(...),程序就死住了
: 。用catch也找不到error,用PreparedStatement也是同样的问题,用新的Connection,St
: atement也不行,反正我能想到的都试过了。----有人说是内存溢出,但是只插入一条记
: 录,怎么会溢出呢?
: 请问各位有没有遇到类似这样的问题,如何解决?BTW,我用的是Oracle, 以前从来没问
: 题的。

avatar
w*y
3
多谢指教----不过我的程序里没有用setAutoCommit----我现在估计也许是我插入的reco
rd的一些attributes 跟其他table的attributes 有 refer关系。


。用catch也找不到error,用PreparedStatement也是同样的问题,用新的Connection,St



【在 xt 的大作中提到】
:
: 了
: 。用catch也找不到error,用PreparedStatement也是同样的问题,用新的Connection,St
: 记
: 问
: Did you check your autocommit setting on your java.sql.Connection? If it is
: false
: you need to explicitly commit or your DB tables will be locked.

avatar
xt
4

这不能解释deadlock.如果是foreign key有问题会有SQLException.

【在 w*********y 的大作中提到】
: 多谢指教----不过我的程序里没有用setAutoCommit----我现在估计也许是我插入的reco
: rd的一些attributes 跟其他table的attributes 有 refer关系。
:
: 住
: 。用catch也找不到error,用PreparedStatement也是同样的问题,用新的Connection,St
: 条
: 没

avatar
w*r
5
foreign key exception should be caught by sqlexception.
My instinct told me that maybe it is the server side, the
admin does not set proper privileage for you.

【在 w*********y 的大作中提到】
: 多谢指教----不过我的程序里没有用setAutoCommit----我现在估计也许是我插入的reco
: rd的一些attributes 跟其他table的attributes 有 refer关系。
:
: 住
: 。用catch也找不到error,用PreparedStatement也是同样的问题,用新的Connection,St
: 条
: 没

avatar
y*i
6
Why not print out the SQL you are trying to execute and run it directly on the
database using the ODBC connecton username/passwd, then you can prove what
wyr's suggestion fit you or not.

reco
。用catch也找不到error,用PreparedStatement也是同样的问题,用新的Connection,St
is

【在 w*r 的大作中提到】
: foreign key exception should be caught by sqlexception.
: My instinct told me that maybe it is the server side, the
: admin does not set proper privileage for you.

avatar
w*r
7
right right.. .this is the basic testing method.. sqlplus will give you
a direct answer...

【在 y****i 的大作中提到】
: Why not print out the SQL you are trying to execute and run it directly on the
: database using the ODBC connecton username/passwd, then you can prove what
: wyr's suggestion fit you or not.
:
: reco
: 。用catch也找不到error,用PreparedStatement也是同样的问题,用新的Connection,St
: is

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。