[Logo]
Forums Register Login
Problem with Vectors
Hello All,
I am having a Java File which uses JDBC. I am using Vectors to access the resultset. My code is working fine if i want to access a single column. But to access all the columns with same Vector, is it possible. I want your suggesstions. Your help is very much appreciated.

Regards,
Raghu
Hi,

You can do it like this :

while(rs.next())
{
for(int i=0;i<noOfColumns-1;i++)
{
vecHold.add(rs.getString(i+1));
}
vecFinal.add(vecHold);
vecHold
}

I believe this way you can do.Hope this solves your problem.
Nilesh
Why don't you create a POJO to store the data from each row instead?
 

Originally posted by Chengwei Lee:
Why don't you create a POJO to store the data from each row instead?



Heck, why don't you just use Hibernate and avoid all of the JDBC code in the first place.
bacon. tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss


This thread has been viewed 451 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jul 15, 2018 16:52:42.