Results 1 to 11 of 11
Thread: how would I display this
- 02-09-2011, 02:19 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 24
- Rep Power
- 0
how would I display this
I created this and cant figure out how to display the return value, if anyone knows please help me out.
Java Code:public List< graduate > getAllPeople() { List< graduate > results = null; ResultSet resultSet = null; try { // executeQuery returns ResultSet containing matching entries resultSet = selectAllPeople.executeQuery(); results = new ArrayList< graduate >(); while ( resultSet.next() ) { results.add( new graduate(resultSet.getInt("studentID"), resultSet.getString("firstName"), resultSet.getString("lastName"), resultSet.getFloat("gpa"), resultSet.getString("Status"), resultSet.getString("mentor"), resultSet.getString("thesisTitle"), resultSet.getString("thesisAdvisor"))); } // end while } // end try catch ( SQLException sqlException ) { sqlException.printStackTrace(); } // end catch finally { try { resultSet.close(); } // end try catch ( SQLException sqlException ) { sqlException.printStackTrace(); close(); } // end catch } // end finally return results; }
- 02-09-2011, 02:21 AM #2
You cannot display a List. What you need to do is iterate over the List and display each item.
- 02-09-2011, 02:34 AM #3
Member
- Join Date
- Jan 2011
- Posts
- 24
- Rep Power
- 0
so how would I do that from another class? I tried this but it says I cannot be referenced from a static context??
Java Code:List results = studentQueries.getAllPeople(); Iterator<results> itr = results.iterator(); while (itr.hasNext()) { results element = itr.next(); stuData.append(element + "\n ");
- 02-09-2011, 02:40 AM #4
In what class is the getAllPeople method?
Is studentQueries a variable of that class?
- 02-09-2011, 02:41 AM #5
By the way, it helps if you copy and paste the EXACT error message. Usually it contains vital information that gets omitted when people paraphrase.
- 02-09-2011, 02:41 AM #6
Member
- Join Date
- Jan 2011
- Posts
- 24
- Rep Power
- 0
studentQueries is the class that contains the method getAllPeople... the above code is in StudentView class
- 02-09-2011, 02:43 AM #7
Member
- Join Date
- Jan 2011
- Posts
- 24
- Rep Power
- 0
exact error "non-static method getAllPeople() cannot be referenced from a static context"
- 02-09-2011, 03:02 AM #8
Wow, your compiler must hate you. Whenever I get error messages they look more like this
My compiler provides lots more information than yours.Java Code:est.java:4: cannot find symbol symbol : method doStuff() location: class Xfoo f.doStuff(); ^ 1 error
- 02-09-2011, 03:04 AM #9
-
- 02-09-2011, 04:04 AM #11
Member
- Join Date
- Jan 2011
- Posts
- 24
- Rep Power
- 0
Similar Threads
-
Display only certain contents of text file and edit display
By blkshrk81 in forum New To JavaReplies: 1Last Post: 12-01-2010, 06:35 PM -
Display on top
By karq in forum New To JavaReplies: 12Last Post: 07-23-2010, 04:59 PM -
What is the different between Text format display on web browser and display on midle
By Basit781 in forum CLDC and MIDPReplies: 1Last Post: 05-31-2010, 08:46 AM -
How to display a list of items and on click display subitems?
By mandyj in forum New To JavaReplies: 8Last Post: 12-29-2008, 07:12 AM -
How to display information about the display device in SWT
By Java Tip in forum SWTReplies: 0Last Post: 06-28-2008, 09:26 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks