Results 1 to 2 of 2
  1. #1
    raj reddy is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default ...............................................

    .............................................
    Last edited by raj reddy; 04-24-2008 at 08:43 AM.

  2. #2
    Join Date
    Apr 2008
    Location
    Fort Wayne, Indiana
    Posts
    62
    Rep Power
    0

    Default

    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:

    Java 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();
    }

Similar Threads

  1. Object and reference
    By katie in forum New To Java
    Replies: 2
    Last Post: 10-19-2009, 04:45 PM
  2. Help In An Critical Query
    By raj reddy in forum JDBC
    Replies: 1
    Last Post: 04-22-2008, 03:24 AM
  3. Replies: 0
    Last Post: 04-15-2008, 09:12 AM
  4. Getting the Object Reference Name
    By Deathmonger in forum New To Java
    Replies: 2
    Last Post: 03-12-2008, 03:51 PM
  5. reference to elements in array
    By Igor in forum New To Java
    Replies: 1
    Last Post: 12-14-2007, 12:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •