Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

CachedRowSet Concurrency

Thread view: 
cksanjose - 14 Nov 2007 16:49 GMT
I have an application that starts a new process every 15 minutes. I
create a new thread for each process so it is possible that they will
run concurrently. I have a data access layer that returns a
CachedRowSet object. When I only have 1 process running, the program
is fine. As soon as another process starts, I start getting errors in
the data access layer.  I get an exception in
"com.sun.rowset.CachedRowSetImpl.populate".
My data access layer method looks like this:

public RowSet retrieve(String sql)
{
   Connection             connection = null;
   ResultSet              resultset  = null;
   CachedRowSet           rowset     = null;
   Statement              statement  = null;

    try
    {
      connection = Current.getConnection();
          statement =
connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
          resultset = statement.executeQuery(sql);
          rowset = new CachedRowSetImpl();
      rowset.populate(resultset);
      resultset.close();
      statement.close();
    }
    catch (SQLException sqle)
    {

          sqle.printStackTrace();
    }

    finally
    {
          connection = null;

    }

    return rowset;
}
Lew - 14 Nov 2007 17:18 GMT
> I have an application that starts a new process every 15 minutes. I
> create a new thread for each process so it is possible that they will
[quoted text clipped - 3 lines]
> the data access layer.  I get an exception in
> "com.sun.rowset.CachedRowSetImpl.populate".

What is the exact message from the exception?

What are the first few exact lines of the stack trace?

> My data access layer method looks like this:

We might need an SSCCE to answer this.  We certainly need to know what the
error is.

<http://www.physci.org/codes/sscce.html>

Creating an SSCCE often helps one discover an answer as they're documenting
the question.

> public RowSet retrieve(String sql)
> {
>     Connection connection = null;

Oh, please do not use TAB characters in Usenet listings!

>     ResultSet  resultset  = null;
>     CachedRowSet rowset   = null;
[quoted text clipped - 3 lines]
> {
>   connection = Current.getConnection();

Hmm - a mysterious undocumented class with a black-box method.  There's no way
this could in any way be involved with the problem.

>   statement =
> connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
> ResultSet.CONCUR_READ_ONLY);
>   resultset = statement.executeQuery(sql);

You may wish to read up on "SQL Injection attacks".

>   rowset = new CachedRowSetImpl();
>   rowset.populate(resultset);
>   resultset.close();
>   statement.close();

Note that exceptions could leave the ResultSet or the Statement not close()d.

What would that induce?

>  }
>  catch (SQLException sqle)
>  {
>     sqle.printStackTrace();

You should also emit the message and the SQL error code.

>  }
>  finally
>  {
>    connection = null;

What do you imagine that this accomplishes?

The variable goes out of scope anyway.  The assignment accomplishes nothing,
and indeed might be optimized away.

>  }
>
>  return rowset;
> }

Signature

Lew

cksanjose - 14 Nov 2007 18:21 GMT
> > I have an application that starts a new process every 15 minutes. I
> > create a new thread for each process so it is possible that they will
[quoted text clipped - 75 lines]
> --
> Lew

Lew,

Thanks for the quick response.

The stack trace is listed but the inner exception error is
ConversionBufferFullException.
The error is:
        com.ibm.db2.jcc.b.SqlException
    at com.ibm.db2.jcc.b.s.a(s.java:1517)
    at com.ibm.db2.jcc.b.s.n(s.java:532)
    at com.ibm.db2.jcc.b.s.W(s.java:1436)
    at com.ibm.db2.jcc.b.kf.a(kf.java:1135)
    at com.ibm.db2.jcc.b.kf.getObject(kf.java:1122)
    at com.sun.rowset.CachedRowSetImpl.populate(CachedRowSetImpl.java:
646)
    at com.gaic.crop.ewa.eWADataAccess.retrieve(eWADataAccess.java:97)
    at com.gaic.crop.ewa.eWADataAccess.retrieve(eWADataAccess.java:64)
    at
com.gaic.crop.ewa.eWARecordTypeFactory08.buildAcreageRecords(eWARecordTypeFactory08.java:
650)
    at
com.gaic.crop.ewa.eWARecordTypeFactory08.build(eWARecordTypeFactory08.java:
160)
    at com.gaic.crop.ewa.eWAJob.run(eWAJob.java:128)
    at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:650)
    at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:675)
    at java.lang.Thread.run(Thread.java:595)
Esmond Pitt - 14 Nov 2007 23:08 GMT
Like Andrew, I'm pretty suspicious of Current.getConnection(). If it
doesn't get you a connection from a driver-managed connection pool it is
almost certainly the source of the problem.
Andrew Thompson - 15 Nov 2007 11:03 GMT
On Nov 15, 10:08 am, Esmond Pitt <esmond.p...@nospam.bigpond.com>
wrote:
> Like Andrew, ...

Andrew who?  Did you mean, 'Lew'?

--
Andrew T.
PhySci.org
Esmond Pitt - 15 Nov 2007 13:27 GMT
> Andrew who?  Did you mean, 'Lew'?

err, oops, yes ...
Daniel Pitts - 15 Nov 2007 16:15 GMT
> On Nov 15, 10:08 am, Esmond Pitt <esmond.p...@nospam.bigpond.com>
> wrote:
[quoted text clipped - 5 lines]
> Andrew T.
> PhySci.org
People tend to confuse you two.  I don't think I've ever mistaken Lew
for Andrew, but maybe some people only read the last two letters? :-)

Joking aside, both of you are very helpful in this community, so I can
see why people confuse you.

Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

Andrew Thompson - 17 Nov 2007 00:59 GMT
On Nov 16, 3:15 am, Daniel Pitts
<newsgroup.spamfil...@virtualinfinity.net> wrote:
> > On Nov 15, 10:08 am, Esmond Pitt <esmond.p...@nospam.bigpond.com>
> > wrote:
[quoted text clipped - 8 lines]
> People tend to confuse you two.  I don't think I've ever mistaken Lew
> for Andrew, but maybe some people only read the last two letters? :-)

If they see the letters SSCCE, they might also get confused.

Lew is the single greatest promoter of the SSCCE (according
to my estimates of seeing 'SSCCE' pop up in my ..Google
Alerts).  Lew mentions SSCCEs more often than I do.

<a little tongue in cheek>
Great minds think alike.
</a little tongue in cheek>

--
Andrew T.
PhySci.org
Lew - 17 Nov 2007 01:57 GMT
> Lew is the single greatest promoter of the SSCCE (according
> to my estimates of seeing 'SSCCE' pop up in my ..Google
[quoted text clipped - 3 lines]
> Great minds think alike.
> </a little tongue in cheek>

I never even heard of SSCCEs until I learned of them from Andrew.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.