I created my first bean and then created a seperate JSP connecting to a database to make sure I have all my connections working.
Now I want to fetch a database value using a bean in JSP that will work with a class file with my database connection.
Java class file:
Please advise how I can do this correctly because I got this error message and need alot of help to get my first bean with database working - INF\classes\colors>javac TestBeany.java TestBeany.java:46: <identifier> expected results.close(); ^ TestBeany.java:47: <identifier> expected conn.close(); ^ 2 errors
Thanks, after I added brace it still doesnt fetch my data. Please advise if I am doing this correctly or another way so I can just get something like this working for me to build on. I just want to fetch a value using a database bean.
Oh. Now I see. You've got a method name that is one character different from one of the most common JDBC method names, so every experienced programmer on the planet is going to see a typo that isn't really there. You should change that method name.
Your compiler is saying that in this method:
the variable mquery is not defined. And it's saying that because it's true. [ June 11, 2006: Message edited by: stu derby ]
Joined: Feb 11, 2006
Thanks it now compiles.
Now I added this to my results loop:
When I pull up my JSP with the bean it shows: Last Name: Jones
The JSP shows one record. But the \Tomcat 5.5\logs show the correct 2 database records so it does work but wont show on the JSP. Please advise what I am doing wrong with my JSP Bean page because it should show two records instead of one:
Joined: Dec 15, 2005
Your bean only returns the last record from the ResultSet; it needs to return a collection, which you iterate over in your JSP.
Joined: Feb 11, 2006
how do I iterate over in JSP?
I know I cant use the results.next in scriptlet but I am not familiar how you use a collection in JSP Bean page so please advise:
[ June 11, 2006: Message edited by: Joseph Smithern ] [ June 11, 2006: Message edited by: Joseph Smithern ]
author & internet detective