Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
    Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

processing resultset

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
author & internet detective
Posts: 39986
806
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
Joe,
Please don't cross-post the same thread multiple times.
 
get schwifty. tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic