In my current investigation of DERBY-2487, I've been working with
jdbc:default:connection, and mostly I've been successful.

However, in some of my tests, I encounter an error:

java.sql.SQLException: No current connection.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:87)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:103)
        at org.apache.derby.impl.jdbc.Util.noCurrentConnection(Util.java:207)
        at 
org.apache.derby.impl.jdbc.EmbedConnectionContext.getNestedConnection(EmbedConnectionContext.java:113)
        at org.apache.derby.jdbc.InternalDriver.connect(InternalDriver.java:176)

The crucial aspect of this error appears to be this code in 
EmbedConnectionContext:

            if ((sc == null) || (sc.getSQLAllowed() < 
org.apache.derby.catalog.types.RoutineAliasInfo.MODIFIES_SQL_DATA))
                throw Util.noCurrentConnection();

Can anybody help me understand the logic behind this code?

Alternatively, here's the problem I'm trying to solve:

At the completion of statement execution, I'm gathering the runtime
statistics regarding the statement, and I want to store that data
into the XPLAIN tables in the database. To do this, I've been
grabbing a connection using code like this:

        InternalDriver id = InternalDriver.activeDriver();
        if (id != null) {
            Connection conn = id.connect("jdbc:default:connection", null);
            if (conn != null)
                return conn;
        }

This generally succeeds in getting me a connection with which I can
execute INSERT statements into the XPLAIN tables. However, in scenarios
such as the following:

        at org.apache.derby.jdbc.InternalDriver.connect(InternalDriver.java:176)
        at 
org.apache.derby.impl.sql.execute.xplain.XPLAINSystemTableVisitor.getDefaultConn(XPLAINSystemTableVisitor.java:2789)
at org.apache.derby.impl.sql.execute.xplain.XPLAINSystemTableVisitor.addStmtDescriptorsToSystemCatalog(XPLAINSystemTableVisitor.java:2805)
        at 
org.apache.derby.impl.sql.execute.xplain.XPLAINSystemTableVisitor.doXPLAIN(XPLAINSystemTableVisitor.java:2730)
        at 
org.apache.derby.impl.sql.execute.NoRowsResultSetImpl.close(NoRowsResultSetImpl.java:375)
        at 
org.apache.derby.impl.sql.execute.InsertResultSet.cleanUp(InsertResultSet.java:2026)
        at 
org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:512)
        at 
org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:416)

I get the "No current connection" thrown from the InternalDriver.connect
method because my current statement context is not allowing a nested
connection to be opened.

Is there a better technique for getting an internal connection to use
for storing the statistics data into the user tables?

thanks,

bryan

Reply via email to