The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001

Advertisement

Advertisement
where you can ask and answer Java programming questions.">
artima.com - a resource for Java and Jini developers
Artima | Search | Java | Design | JVM | Jini | Books | Seminars | Subscribe 


Java Answers Forum
April 2001

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Hashtable.put ( Object, Object ) is correct signature

Posted by Kishori Sharan on May 02, 2001 at 11:47 PM

Hi
You were getting error because your records variable was defined as Hashtable and you were treating it as an array of Hashtable. But, now you got it straight. The problem with the following code is :
records[i].put(row, rs.getString(i+value));

the put method in Hashtable takes two parameters and they are objefts and you are passing the first parameter as int. So you mey want to pass the first parameter which is row no. as Integer object and in that case your method call will change to

records[i].put(new Integer (row), rs.getString(i+value));
Or, you just convert your row numeber into a string object as:
records[i].put(""+row, rs.getString(i+value));

Now you need to pay attention while you want to read the value using row number. Since key in Hashtable is an object and you will be using either Integer object or String object , so you need to use one of these objects to read the value.

Thanks
Kishori





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us