•
•
•
•
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
![]() |
•
•
Join Date: Sep 2007
Posts: 7
Reputation:
Rep Power: 0
Solved Threads: 0
Search.java:
SearchResults.java:
obviously I'm getting errors from the last 5 lines in SearchResults.
I'm trying to get 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.
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();
}![]() |
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- /etc/Sysctl.conf really i need it? (*nix Software)
- images no longer animated (Web Browsers)
- Registering Domains (Web Hosting Deals)
- PHP file handling (PHP)
- Help with HiJackThis log, please (Viruses, Spyware and other Nasties)
- can only open my documents after connecting to internet (Web Browsers)
- hijacked, with log please help (Viruses, Spyware and other Nasties)
- Disappearing Drive in Win XP (Storage)
Other Threads in the JSP Forum
- Previous Thread: Another MySQL issue...
- Next Thread: Is this standard JSP behavior?


Linear Mode