• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Vectors  RSS feed

 
Raghuraman Muthuswamy
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nilesh Srivastava
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you create a POJO to store the data from each row instead?
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!