| Author |
Q: repeatedly execute() on PreparedStatement without close()
|
Yan Zhou
Ranch Hand
Joined: Sep 02, 2003
Posts: 136
|
|
Hi, I wonder if I can repeatedly call executeUpdate() on a PreparedStatement without closing the statement? Like this: Would this have problem of leaking resource? Yan
|
 |
Annie Smith
Ranch Hand
Joined: Mar 05, 2005
Posts: 172
|
|
Yes, it might. Oracle, for instance, throws up a runtime exception saying "maximum number of cursors exceeded..."
|
Cheers!<br /><b>Annie</b>
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12909
|
|
For updating a number of rows this way, you'd better use addBatch() and executeBatch(). See the API documentation of classes java.sql.PreparedStatement and java.sql.Statement.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: Q: repeatedly execute() on PreparedStatement without close()
|
|
|