English 中文(简体)
j子中 cur子的 cur子
原标题:clarification of cursors in oracle with jdbc

我有这样的情况,即我使用的第3个政党开放源产品从Oracle的 cur子中挥发,并收到错误:java.sql.SQLException: ORA-01000:最大开场治疗器超过顶

我的最高治标人定为1,000人,如果达到这一限制的守则不正确,或者如果我只需要增加我的限额,我就试图指出这一点。

进行了一些调查 我在《法典》中看到了设立“ResultSet”的一点,从而把我的开张 cur子增加到1。 然而,该ResultSet在使用后很快就关闭了......BUT, cur子仍留在原地。 在第三党开放源项目之外,我得以在简便的JDBC应用中复制这一逻辑。

package gov.nyc.doitt.cursor;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class CursorTest {
    public static void main(String[] args) {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;

        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            conn = DriverManager.getConnection("jdbc:oracle:thin:@myhost:1537:mydb", "username", "password");

            // as expected: there are 0 cursors associated with my session at this point

            ps = conn.prepareStatement("select my_column from my_table where my_id = ?");
            ps.setInt(1, 86);

            // as expected: there are 0 cursors associated with my session at this point

            rs = ps.executeQuery(); // opens 1 cursor

            // as expected: there is 1 open cursor associated with my session at this point
        } catch (Throwable t) {
            t.printStackTrace();
        } finally {
            // as expected: there is 1 open cursor associated with my session at this point
            try {
                rs.close();
            } catch (SQLException e) {
                System.err.println("Unable to close rs");
            }
            // not expected: there is still 1 open cursor associated with my session at this point
            try {
                ps.close();
            } catch (SQLException e) {
                System.err.println("Unable to close simplePs");
            }
            // not expected: there is still 1 open cursor associated with my session at this point
            try {
                conn.close();
            } catch (SQLException e) {
                System.err.println("Unable to close conn");
            }
            // as expected: at this point my session is dead and so are all the associated cursors
        }
    }
}

我发现一些Oracle文件,使我想,如果你关闭我们的ResultSet和编写声明,所有开张的治疗师都将关闭,但我的开张治疗师似乎正在hang。 See this FAQ ( http://download.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm#1006509 后者说,“公布结果集或声明释放了数据库中相应的 cur”。 我的检验似乎没有发生,因此我必须缺乏一些基本的理解。

谁能解释一下Oracle如何处理 cur子,或者把我引向一些将给我开明的文件?

感谢!

最佳回答

很久以前,我就遇到了类似的问题。 我记得,这个问题正在拖延垃圾收集。 在垃圾收集器发现并释放适当物品之前,数据库治疗器取得了近距离。 如果发言经常发表,你就可以处理这个问题。 1. 经常人工援引垃圾收集器:

Runtime r = Runtime.getRuntime();
r.gc();

只是要检查这种说法。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签