View Single Post
  #2 (permalink)  
Old 04-15-2008, 01:09 PM
Chris.Brown.SPE's Avatar
Chris.Brown.SPE Chris.Brown.SPE is offline
Member
 
Join Date: Apr 2008
Location: State College, PA
Posts: 50
Chris.Brown.SPE is on a distinguished road
Send a message via AIM to Chris.Brown.SPE
You have to return an ArrayList back to the main function and save it into a variable in the scope of the main function. Like so:

ArrayList x;
x = fetchTicketkey();

When i did this it said "cannot convert from list to arraylist so i changed your function to return an ArrayList instead of an Array. So the whole thing would look like this:

Code:
public ArrayList fetchTicketkey() { ArrayList li = new ArrayList(); String str=""; try { String query = "select tktkey from tktgame2day1 where start_draw=1"; System.out.println("IN THE METHOD "); con=databaseConnection.getConnection(); pstmt=con.prepareStatement("query"); rs=pstmt.executeQuery(); while(rs.next()) { li.add(rs.getString("area_name")); } rs.close(); con.close(); } catch(Exception e) { System.out.println(" ERROR in getting the values from tktgame2day1 Table "+e); } return li; } public static void main(String[] args) { ArrayList x; x = fetchTicketkey(); }
Reply With Quote