aspose file tools*
The moose likes JDBC and the fly likes processing resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

processing resultset

joe weakers
Ranch Hand

Joined: May 31, 2004
Posts: 38
Hi there. I am connecting to an Oracle database using Oracle JDBC drivers and all that kind of thing. I then send sql select statements to retrieve the necessary information. Everything is fine to this point. The results of my query are then loaded into an OraceResultSet which contains two columns (my select statement requests string and float values from the one table). My dilemma is as follows. When parsing the result set is there a way of accessing the values stored in the two columns of the resultset based on their type. In my database table I have two columns: feature_name of type varchar2 and feature_weight of type float. Therefore the result set is a mirror image of this table. My code looks as follows:

OracleResultSet ors = (OracleResultSet) stmt.executeQuery(query);

while (ors.next()){
for(int i = 1; i <= 2; i++){
Object dbObject = ors.getObject(1);
weights.addElement(dbObject);
}
}

This code adds all the feature_names to a "weights" vector, i.e. ors.getObject(1). What I would like to do is set the weight of each feature_name to be its corresponding feature_weight in the database table using code like as follows:

public void setFeatureWeight(float weight){
this.weight = weight;
}

This is where my problem arises. How do I call my setFeatureWeight method when the elements of the second column in the OracleResultSet are not of type float. has anyone any suggestions? thank you Joe
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30753
    
156

Joe,
Please don't cross-post the same thread multiple times.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: processing resultset