IT Community - Software Programming, Web Development and Technical Support

"Cannot Find Symbol" when I trying Vector to ArrayList

This is a discussion on "Cannot Find Symbol" when I trying Vector to ArrayList within the Java Programming forums, part of the Software Development category; I am changing from Vectors to use Arraylists with the new generics arraylists. My original code to read an SQL ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Java Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 10-12-2007, 12:22 AM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 325
amansundar is on a distinguished road
Question "Cannot Find Symbol" when I trying Vector to ArrayList

I am changing from Vectors to use Arraylists with the new generics arraylists.

My original code to read an SQL table and save the rows into a Vector:

Code:
private Vector llenaVectorConceptos(Vector VectorConceptos) {
ResultSet rs=null;
Vector vectorConceptos = new Vector(); 
try{
rs=stmt.executeQuery("Select * from Conceptos order by CONCEPTODESCRIPCION");
while(rs.next())
{
vectorConceptos.add(rs.getString("CONCEPTODESCRIPCION") + " > " + rs.getString("TIPO") + " > " + rs.getString("NUMCONCEPTO"));
}
}
catch(SQLException e){
System.out.println(e);
}
mdbc.close(rs);
return vectorConceptos; 
}
the problem is that i want to change these vectors just to use arraylists.
See the new code:

Code:
private ArraList llenaVectorConceptos(ArraList VectorConceptos) {
ResultSet rs=null;
ArraList<String> vectorConceptos = new ArraList<String>(); 
try{
rs=stmt.executeQuery("Select * from Conceptos order by CONCEPTODESCRIPCION");
while(rs.next())
{
vectorConceptos.add(rs.getString("CONCEPTODESCRIPCION"), rs.getString("TIPO"));
}
}
catch(SQLException e){
System.out.println(e);
}
mdbc.close(rs);
return vectorConceptos; 
}
During compilation appears this message : "Cannot Find Symbol" in the

Code:
vectorConceptos.add(rs.getString("CONCEPTODESCRIPCION"), rs.getString("TIPO"));
Netbeans compiling output :

symbol : method add(java.lang.String,java.lang.String)
location: class java.util.ArrayList<java.lang.String>
vectorConceptos.add(rs.getString("CONCEPTODESCRIPC ION"), rs.getString("TIPO"));


Is any Idea?
__________________
cheers
Aman
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-20-2007, 01:47 AM
latchu latchu is offline
D-Web Trainee
 
Join Date: Sep 2007
Posts: 21
latchu is on a distinguished road
Exclamation Re: "Cannot Find Symbol" when I trying Vector to ArrayList

mm…fine…

I think i found the problem. the .add method for the arraylist only accept (1) value, i am trying to enter (2) values:

vectorConceptos.add(rs.getString("CONCEPTODESCRIPC ION"), rs.getString("TIPO"));

When i change the statement to :
vectorConceptos.add(rs.getString("CONCEPTODESCRIPC ION"));
the compilation message disappears.
But now i have a new problem after changing this, I need an array with two columns, i mean, 1st column to hold the "CONCEPTODESCRIPCION" and a 2nd column to hold the "TIPO".

Can it be possible using this kind of arraylis or i need another arraylist?

Some example?

Thanks again...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-28-2007, 02:18 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Smile Re: "Cannot Find Symbol" when I trying Vector to ArrayList

Hi
You've changed Vector to ArrayList ok.

It looks like you are also trying to change what you store in your collection.
Previously you were storing a single String, now you want to store a more complex collection of information. You have a variety of options. One simple option is to use a String array.

Code:
ArrayList<String[]> vectorConceptos = new ArrayList<String[]>();
vectorConceptos.add(new String[] {rs.getString("CONCEPTODESCRIPCION"), rs.getString("TIPO")});
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the use of " - > " symbol in PHP? S.Vinothkumar PHP Programming 4 11-04-2007 10:58 PM
I keep getting "Data Missing" when I click the "back" button in my browser. How can I oxygen HTML, CSS and Javascript Coding Techniques 1 07-28-2007 01:12 AM
Diffrence between a "assignment operator" and a "copy constructor" Sabari C and C++ Programming 1 07-24-2007 05:00 AM
Difference between "vector" and "array"? Sabari C and C++ Programming 1 07-24-2007 04:33 AM
Why do I get "HTTP 500" error(or "(DLL)initialization routine failed")in my browser? kingmaker ASP and ASP.NET Programming 1 07-20-2007 04:38 AM


All times are GMT -7. The time now is 11:03 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0