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 / December 2005

Tip: Looking for answers? Try searching our database.

ResultSet findColumn - expensive to execute?

Thread view: 
timasmith@hotmail.com - 11 Dec 2005 19:06 GMT
Hi,

I have a method which maps resultsets to objects - one row only in this
method.

I have several different SQL, with different columns selected - each
using the same method.

Is the following expensive to execute for every column for every row?

try {
   rset.findColumn(columnName);
} catch (SQLException se) {

}

I use it to check that the column is in the resultset - prior to
executing the copy of the value to the model.  Is this too expensive to
run - if I had 100 rows returned with 10 columns, it would run a 1000
times.  But perhaps this is negligible compared to other overhead?

Is there a better way to execute the various getString, getInt etc. for
only columns in the resultset?

thanks

Tim
Marc E - 11 Dec 2005 20:29 GMT
i can't answer this, but you might download the source for jakarta's DBUtils
package, which does resultset-->object mapping, and see how they do it. I've
found the resultset-to-bean stuff to be reasonably speedy, at least for
modestly sized resultsets.

> Hi,
>
[quoted text clipped - 23 lines]
>
> Tim
Roedy Green - 11 Dec 2005 20:34 GMT
>Is the following expensive to execute for every column for every row?
>
>try {
>    rset.findColumn(columnName);
>} catch (SQLException se) {

It may well depend on the JDBC driver. You had best test your
particular case.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Thomas Hawtin - 11 Dec 2005 21:17 GMT
> Is the following expensive to execute for every column for every row?
>
[quoted text clipped - 3 lines]
>
> }

If you are going to only use the column index, you might as well use the
 getXxx(String) variant (assumes you are not using wasNull).

I wouldn't bother catching SQLException at every method invocation.

It would take a very broken driver for the small table look up to be
anything other than tiny. Relative to executing SQL over a network
connection, it is absolutely negligible.

You might want to optimise it, just so that there is one less thing to
worry about. This is the sort of nonsense code which is suited to
automation.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/



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.