When I was tested yesterday: Error Setting Up Static Cursor Cache said this is because the File Descriptor held by a process is excessive. I checked an afternoon, I found that it was caused by Microsoft's SQL Server JDBC driver, but it was indeed our own coded mistake, and did not close some corresponding resources.
In the system, the error is very deep, I tried many times, I finally reappeared the error, the code as follows: try {connection conn = ........ // Note that the connection may be obtained from the connection pool DatabaseMetadata dbm = conn.getMetadata ();
// Get all tables in the source of information (INT i = 0; i <100; i ) {long start = system.currenttimemillis ();
// Get all tables in the source of the resultset RS = dbm.gettables (null, null, null, new string [] {"Table"}); while (rs.next ()) {string TableName = rs.getstring (3); // Get the name of the table ResultSet RS1 = dbm.getColumns (Null, Null, TableName, NULL);
While (RS1.Next ()) {r1.getstring (4);} ResultSet RS2 = dbm.getimportedKeys (Null, Null, TableName); while (rs2.next ()) {r2.getstring (4);} ResultSet RS3 = dbm.getexportedKeys (null, null, tablename); while (RS3.Next ()) {r3.getstring (8);} ResultSet RS4 = dbm.getPrimaryKeys (Null, Null, TableName); while (rs4.next () ) {R4.getstring (4);
} Long end = system.currenttimemillis (); system.out.println (">>> " i ": " (end - start));} conn.close (); // Here the close method, and Do not really close the connection, just put it in the buffer pool} catch (sqlexception e) {E.PrintStackTrace ();
}} The above code acquires all the tables of a database, the primary key, foreign key, etc. of the table, and there will be errors in the FOR cycle on my machine. The reasons are as follows: SQL Server JDBC uses a large number of temporary files (in the directory specified by java.io.tmpdir), but if not close the ResuletSet, JDBC does not release the HANLDER of these files. So when obtaining a number of databases SCHEMA, the current process holds a lot of file HANLDER, this time, JDBC will throw an exception of "Error Setting Up Static Cursor Cache". So if you don't use it, you must remember it, otherwise you will have endless suffering.