SQLJ question - ConnectionContext and DefaultContext

SQLJ question - ConnectionContext and DefaultContext

Post by Steve Sanya » Fri, 09 Jun 2000 04:00:00



In SQLJ, you can either declare your own contexts as follows:

#sql context MyContext;

or you can simply instantiate multiple copies of DefaultContext.

My question is simply -- why would you need to use anything other than the
DefaultContext?

Are there any good sites that lead you through SQLJ techniques?

Regards
Steve

 
 
 

1. SQLJ ConnectionContext leaks memory

Has anyone experienced, or observed an Oracle SQLJ program
leak memory?

In a SQLJ program, when using the ConnectionContext with a
database connection pool manager, the ConnectionContext leaks
memory unless it is explicitly closed.  The documentation states
that it should be possible to free the resources associated with
the ConnectionContext but leave the database connection intact.
Closing the database connection defeats the performance boost
gained by using a connection pool manager.

By the way, explicit ConnectionContexts are used here since
this is called from a RMI server which is multi-threaded.

Example program,

#sql context DatabaseContext
#sql iterator MessageIter (String FOO);

public class AppMessageHandler
{
...
public void GetMessages ()
{
    // Get connection from connection pool.
    Connection dbConn = AppConnectionManager.getConnection();

    // Allocate SQLJ connection context.
    DatabaseConnection dbContext = new DatabaseConnection(dbConn);

    MessageIter messageIter;

    try {
        #sql [dbContext] messageIter = { SELECT FOO FROM BAR };
        while (messageIter.next()) {
            System.out.println("message:" + messageIter.FOO());
        }
        messageIter.close();
    }
    catch (SQLException exc) {
        ...
    }
    finally {
        // Deallocate SQLJ connection context.
        //dbContext.close();  -- THIS DOES NOT LEAK, BUT CLOSES DB
CONNECTION.
        dbContext.close(ConnectionContext.KEEP_CONNECTION);  -- THIS
LEAKS

        // Release connection to connection pool.
        App ConnectionManager.releaseConnection(dbConn);
    }

------------------------------------------
Stuart

2. List of Tables?

3. SQLJ call to SQLJ stored procedure

4. Stored Procedure vs ESQL/C

5. ConnectionContext class in MS SQL Server

6. 15921-NJ-Cranford-ORACLE-SQL-Communication Skills-Project Manager

7. Sqlj question

8. Pdox4.5...Creation of huge .xx file

9. SQLJ Question on respondnet.com

10. A question of SQLJ

11. SQLJ question

12. Advice required: JDBC/SQLJ or ADO ?

13. SQLJ and SQL server