User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 456,489 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,710 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 750 | Replies: 1
Reply
Join Date: Sep 2007
Posts: 7
Reputation: MonkeyGarage is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
MonkeyGarage MonkeyGarage is offline Offline
Newbie Poster

Last issue was resolved... but hey, I've got another

  #1  
Sep 19th, 2007
Search.java:
package com.monkeygarage.carclubhub.clubinfo;
import java.sql.ResultSet; 
import java.sql.SQLException; 
import java.util.logging.Logger;
import com.monkeygarage.DBConnect;
import java.util.logging.Level;
import java.util.*;

public class Search 

{
	private List<SearchResults> list = new ArrayList<SearchResults>(); 
	DBConnect db = new DBConnect(); 
		public Iterator getResult() {
		Result();
		return list.iterator();
		}
	
	
	private void Result()
	{
		try {
			ResultSet rs = db.getResult("SELECT club.clubId, " +
					"club.clubName, club.clubDescrip, " +
					"clubaddress.zipcode, state.stateName FROM club, " +
					"clubaddress, state WHERE clubaddress.stateId=38 " +
					"AND clubaddress.clubId = club.clubId AND " +
					"clubaddress.stateId = state.stateId");
			
			list = new ArrayList();
			
			while(rs.next())
					{
				list.add(new SearchResults(rs.getLong(1), rs.getString(2),
						rs.getString(3),rs.getLong(4),rs.getString(5)));
					}
			}		
		catch (SQLException ex) {LOGGER.log(Level.SEVERE, "Error", ex);}
					
	
			
			finally 
			{ db.disconnect(); } 
				
	
		}
	private static final Logger LOGGER = Logger.getLogger(Search.class.getName());
	public static void main(String[] args) {
		Search list = new Search();
		Iterator it = list.getResult();
		
	
		}

}


SearchResults.java:
package com.monkeygarage.carclubhub.clubinfo;

public class SearchResults {
	private Long clubId;
	private String clubName;
	private String clubDescrip;
	private Long zipcode;
	private String stateName;
	
	SearchResults(Long clubId, String clubName,
	String clubDescrip,
	Long zipcode,
	String stateName)
	{
		this.clubId=clubId;
		this.clubName=clubName;
		this.clubDescrip=clubDescrip;
		this.zipcode=zipcode;
		this.stateName=stateName;
	}
	
	public Long getClubId(){
		return clubId;
	}
	
	public String getClubName(){
		return clubName;
	}
	
	public String getClubDescrip(){
		return clubDescrip;
	}
	
	public Long getZipcode(){
		return zipcode;
	}
	
	public String getStateName(){
		return stateName;
		}
	
	public Long toLong() { return this.clubId; }
	
	public String toString() { return this.clubName; }
	
	public String toString() { return this.clubDescrip; }
	
	public Long toLong() { return this.zipcode; }
	
	public String toString() { return this.stateName; }
}

obviously I'm getting errors from the last 5 lines in SearchResults.

I'm trying to get
public static void main(String[] args) {
		Search list = new Search();
		Iterator it = list.getResult();
		
	
		}
to actually output the results, but I'm a little confused as to how, and I also wanted to make sure I was using generics correctly, though I don't think I am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 7
Reputation: MonkeyGarage is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
MonkeyGarage MonkeyGarage is offline Offline
Newbie Poster

Re: Last issue was resolved... but hey, I've got another

  #2  
Sep 19th, 2007
can an arraylist hold a table of items similiar to the results of a mysql request? I've got 5 items coming out of the request, and from everything I see about ArrayList, it gives you a an "id" column and an "item" column...
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 3:15 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC