The compiler needs to know the field names at compile time. You might want
to consider creating a AssetHash table that contains each of your Asset
objects indexed by your assetid.
eg:
Hashtable assetHash = new Hashtable();
while (assetResults.rs.next()) {
String id = assetResults.rs.getString("assetid");
String name = assetResults.rs.getString("filename");
String path = assetResults.rs.getString("filepath");
assetHash.put(assetResults.rs.getString("assetid"), new
Asset(id, name, path,dbase, out);
}
.
.
.
Asset getAsset(String id){
return (Asset)assetHash.get(id);
}
John Zerbe - Mellon Bank
IM&R - Middleware Team
Phone: 412-234-1048 E-Mail:[EMAIL PROTECTED]
> -----Original Message-----
> From: Java List [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, August 10, 1999 4:58 PM
> To: [EMAIL PROTECTED]
> Subject: Java Object
>
> This is more of a general Java question....servlet related.
>
> I've written a class called "Assets" from which "Asset" objects are
> created for each found record in a database. The Asset object contains a
> hash with name/value pairs of the fields in the database and also a bunch
> of methods for sifting through these hashes. (or ashes ....ha ha!)
>
> The Asset objects are created in a while loop (see the code below ) and
> I'm trying to name the Asset objects dynamically based on the key field
> (assetid) in the found ResultSet. For instance if the ResultSet contains
> four found assets and the key fields (assetid) of each are values such as
> 67,143,69 and 24 I'd like to name the Asset object with these
> fields...but the compiler isn't allowing it. The compiler wants only a
> plain ASCII string when naming the object...it gives me an Invalid
> Declaration error. Any suggestions or work arounds?
>
> -----------------------
> while (assetResults.rs.next()) {
> String id = assetResults.rs.getString("assetid");
> String name = assetResults.rs.getString("filename");
> String path = assetResults.rs.getString("filepath");
>
> Asset assetResults.rs.getString("assetid")= new Asset(id, name,
> path,
> dbase, out);
> // The line above is what I'd like to do but the compiler gives
> an
> Invalid Declaration.
> }
> ---------------------------
>
> Thanks,
>
> -Nash
>
> __________________________________________________________________________
> _
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html