JDBC best practice

From: "Dave Held" <dave(dot)held(at)arrayservicesgrp(dot)com>
To: <pgsql-performance(at)postgresql(dot)org>
Subject: JDBC best practice
Date: 2005-03-28 22:58:55
Message-ID: 49E94D0CFCD4DB43AFBA928DDD20C8F90261848E@asg002.asg.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

I'm using a Postgres table as the data source for a JTable
in a Java app. As a first approximation, I'm implementing
AbstractTableModel.getValueAt() like so:

public Object getValueAt(int row, int col)
{
try
{
rs_.absolute(row + 1);
return rs_.getObject(col + 1);
}
catch (Exception e)
{
...
}
return null;
}

Where rs_ is a RecordSet object. What I'm wondering is
whether it's better to call absolute() or relative() or
next()/previous(). If absolute() is the slowest call,
then I can cache the last row fetched and move relative
to that.

My suspicion is that next()/previous() is much faster
than absolute() when the record to be fetched is very near
the last record fetched. I haven't actually tried it, but
I'd like some insight if others can already answer this
question based on knowledge of the server side and/or the
JDBC driver.

__
David B. Held
Software Engineer/Array Services Group
200 14th Ave. East, Sartell, MN 56377
320.534.3637 320.253.7800 800.752.8129

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Simon Riggs 2005-03-28 22:59:11 Re: Delete query takes exorbitant amount of time
Previous Message Cott Lang 2005-03-28 22:43:14 Re: How to improve db performance with $7K?