Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
10.8.3.0
-
None
-
Normal
-
Repro attached, Workaround attached
Description
With client/server, depending on when garbage collection kicks in metadata related statements can build up until garbage collection. This is only potentially an issue I think with client where there is a limit of 32K statements and only if there is some sort of extremely deferred garbage collection.
The program below shows the issue which is easy enough to work around by closing the statement associated with the metadata result set, uncommenting the line.
//rs.getStatement().close();
import java.sql.*;
import java.net.*;
import java.io.*;
import org.apache.derby.drda.NetworkServerControl;
/**
- Show client/server Metadata statements can build up even when
- Metadata result sets have been closed.
*/
public class MetaDataStatements {
public static void main(String[] args) throws Exception {
try {
// Load the driver. Not needed for network server.
Class.forName("org.apache.derby.jdbc.ClientDriver");
// Start Network Server
startNetworkServer();
// If connecting to a customer database. Change the URL
Connection conn = DriverManager
.getConnection("jdbc:derby://localhost:1527/wombat;create=true");
// clean up from a previous run
Statement s = conn.createStatement();
try
catch (SQLException se)
{ if (!se.getSQLState().equals("42Y55")) throw se; } for (int i = 0; i < 50000; i++) {
ResultSet rs = conn.getMetaData().getSchemas();
while (rs.next())
//rs.getStatement().close();
}
// rs.close();
// ps.close();
// s.close();
runtimeInfo();
conn.close();
// Shutdown the server
shutdownServer();
} catch (SQLException se) {
while (se != null)
}
}
/**
- starts the Network server
*/
public static void startNetworkServer() throws SQLException {
Exception failException = null;
try {
NetworkServerControl networkServer = new NetworkServerControl(
InetAddress.getByName("localhost"), 1527);
networkServer.start(new PrintWriter(System.out));
// Wait for the network server to start
boolean started = false;
int retries = 10; // Max retries = max seconds to wait
while (!started && retries > 0) {
try
catch (Exception e)
{ retries--; failException = e; }}
// Check if we got a reply on ping
if (!started)
} catch (Exception e)
{ SQLException se = new SQLException("Error starting network server"); se.initCause(failException); throw se; }}
public static void shutdownServer() throws Exception
{ NetworkServerControl networkServer = new NetworkServerControl( InetAddress.getByName("localhost"), 1527); networkServer.shutdown(); }public static void runtimeInfo() throws Exception
{ NetworkServerControl networkServer = new NetworkServerControl( InetAddress.getByName("localhost"), 1527); System.out.println(networkServer.getRuntimeInfo()); }}
---------- Session Information ---------------
Session # :2
Database :wombat;create=true
User :APP
- Statements:59
Prepared Statement Information:
Stmt ID SQLText-
-
-
-
-
-
-
-
-
-
-
- -----------
SYSLH00032 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
SYSLH00033 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
SYSLH00060 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
SYSLH00058 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
SYSLH00059 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
SYSLH00056 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
SYSLH00057 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
SYSLH00054 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
SYSLH00055 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
- -----------
-
-
-
-
-
-
-
-
-
-
-
Attachments
Issue Links
- relates to
-
OPENJPA-2329 OpenJPA should close JDBC metadata (and all) statements
-
- Open
-