• Post Reply 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Problem with Vectors  RSS feed

 
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
 
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
 
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?
 
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!