ObjectWeb Consortium
Search ObjectWeb Mail Archive: 

Advanced Search - Powered by Google

Mail Archive Home | c-jdbc List | May 2005 Index

<--  Date Index  --> <--  Thread Index  -->

Re: [c-jdbc] Problems Executing Stored Procedures

Hi Emmanuel,

On 28-May-05, at 7:06 AM, Emmanuel Cecchet wrote:

You will just run all connections in proxying mode. What if you try to override driverProcessed to true in the URL, does it work?

I've checked out the code this morning and setting driverProcessed=false in our connection URL now works properly.  That being said, I am now having a few issues that I didn't see at the end of last week.  All of these issues occur when driverProcessed is set to false:

1.  I get a NullPointerException when performing a SELECT statement and the SqlSkeleton variable is not 'null'.  I debug to this piece of code in AbstractLoadBalancer.java:

      if (request.isDriverProcessed() || (request.getSqlSkeleton() == null))
        s = c.createStatement();
        s = c.prepareStatement(request.getSqlSkeleton());
            (PreparedStatement) s);

Because driverProcessed is false, we go into the 'else' portion, which calls setPreparedStatement.  In this code:

    // Set all parameters
    while ((i = sql.indexOf(AbstractDriverConnection.START_PARAM_TAG, i)) > -1)

There are no parameters (we are performing a simple SELECT * FROM tablename), but the NullPointerException occurs when accessing the START_PARAM_TAG variable.  This variable in AbstractDriverConnection is not initialized.  I updated the code to match the same variables in the driver Connection.java code, such as:

  /** Tag maker for PreparedStatement parameters */
  public static final String    TAG_MARKER                    = "!%";
  /** Escape for tag maker */
  public static final String    TAG_MARKER_ESCAPE             = TAG_MARKER
                                                                  + ";";
  /** Tag for PreparedStatement parameters start delimiter */
  public static final String    START_PARAM_TAG               = "<"
                                                                  + TAG_MARKER;
  /** Tag for PreparedStatement parameters end delimiter */
  public static final String    END_PARAM_TAG                 = "|"
                                                                  + TAG_MARKER
                                                                  + ">";

This seemed to fix that issue.

2. When performing a stored procedure that does a read in the following form select * from procedure(param1, param2), I get an SQLException thrown because there is a 'null' value that surrounds the parameters.  For example, when calling setPreparedStatement, the value of SQL is:

SELECT * FROM somefunc(null0|truenull)

It hits the same portion of code above (testing for the START_PARAM_TAG), and the while loop doesn't execute because it cannot find any instance of "null".  I know that I've probably broken this by changing the value of the TAGS and TAG_MARKER variables to something other than null, but if I keep them as null then I get a NullPointerException when doing the test of the while statement.

So, it looks like when the SQL statement is being read from the stream, the values for the markers aren't getting set properly.  I will do some more investigating, but do you (or anyone else) also see this issue with using driverProcessed=false?  I'm thinking that the "null" values surrounding the parameters above should be surrounded by the static variables used as markers, then when the while loop is executed, it can extract these parameters and enter them into the SqlSkeleton variable.

Just as an FYI, this code worked previous to the weekend when I manually set the default of driverProcessed=false in the Driver Connection.java.  If I now make the same change to the default value and remove the parameter from my connection URL, I am seeing the same behavior.


Dylan Hansen
How2Share Technologies

<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 1999-2005, ObjectWeb Consortium | contact | webmaster.