| | |
retrieving data from database into jsp page
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jul 2008
Posts: 50
Reputation:
Solved Threads: 0
hi stephens,
i promise you that i would go through the jdbc tutorial entirely and get all the concepts clear but right now i have to get this done as soon as possible.if you could just tell me how to write the code for now it would be a great favour.only for this time help me with the code for this particular scenario.Please help.
i promise you that i would go through the jdbc tutorial entirely and get all the concepts clear but right now i have to get this done as soon as possible.if you could just tell me how to write the code for now it would be a great favour.only for this time help me with the code for this particular scenario.Please help.
That shows that you have not put in an effort to go through either of my links, why should I help you then, for a guy of average IQ that should be no more than an hours work and what guarantees that you will go through the tutorial when you no longer need it.
The major reason I am not revealing the mistake is cause the mistake is too simple.
The major reason I am not revealing the mistake is cause the mistake is too simple.
Last edited by stephen84s; Sep 12th, 2008 at 2:58 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
First run Peter's Query in your DBMS and see how the results are displayed.
Next if your JDBC concepts are good go to my second link first (the one pointing to the javadocs of the ResultSet interface).
If the answer still doesn't click, then I guess you will need to go through the tutorial till you get what you want.
Trust me if you find and correct these small mistakes yourself, you will know how to go about larger problems.
Also I will tell you where you are going wrong you are expecting all the three parameters for SL,PL and CL in one row like:.
Whereas when you run the query given by Peter attached with the
Note the use of the order by clause to force the database to sort the way the records are stored in your ResultSet so that you will always get "cl", "pl" and "sl" in that order in your ResultSet and not in the order their rows were inserted.
You would get three rows like this:-
So you have to just change your code to search for CL,PL and SL vertically rather than horizontally(i.e in one row).
Next if your JDBC concepts are good go to my second link first (the one pointing to the javadocs of the ResultSet interface).
If the answer still doesn't click, then I guess you will need to go through the tutorial till you get what you want.
Trust me if you find and correct these small mistakes yourself, you will know how to go about larger problems.
Also I will tell you where you are going wrong you are expecting all the three parameters for SL,PL and CL in one row like:.
JSP Syntax (Toggle Plain Text)
PL CL SL 30 7 7
Whereas when you run the query given by Peter attached with the
order by clause as shown here:- sql Syntax (Toggle Plain Text)
SELECT m_leavetype, m_bal FROM TABLENAME WHERE m_emp_no='1004' ORDER BY (m_leavetype);
You would get three rows like this:-
JSP Syntax (Toggle Plain Text)
m_leavetype m_bal cl 7 pl 30 sl 7
So you have to just change your code to search for CL,PL and SL vertically rather than horizontally(i.e in one row).
Last edited by stephen84s; Sep 12th, 2008 at 3:19 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
Would you mind tell us what it was?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Hmmm ........... my crystal ball tells me my previous post was correct !!!
But I could be wrong cause I am using a cheap third world imitation of a crystal ball (a paper weight to be exact
).
But I could be wrong cause I am using a cheap third world imitation of a crystal ball (a paper weight to be exact
). "Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
•
•
Join Date: Jul 2008
Posts: 50
Reputation:
Solved Threads: 0
hi stephens and peter,
Actually the same code which both of you provided was very much correct but i was doing mistake from my side. i was confused with the display part into the jsp page because when i was retrieving values from the database i was getting all the values properly but when i had to display into the jsp page i was taking the string value stored in session from the previous page and not from the database bcz of which it was giving me only the first row value. but finally bcz of your help i have found the solution .
thanks to both of you.
bye take care
Actually the same code which both of you provided was very much correct but i was doing mistake from my side. i was confused with the display part into the jsp page because when i was retrieving values from the database i was getting all the values properly but when i had to display into the jsp page i was taking the string value stored in session from the previous page and not from the database bcz of which it was giving me only the first row value. but finally bcz of your help i have found the solution .
thanks to both of you.
bye take care
•
•
Join Date: Nov 2007
Posts: 34
Reputation:
Solved Threads: 0
•
•
•
•
Have look at this tutorial. It is not finished yet, however you can use it for initial start
Your tutorial is great! It fully explains MVC working with database and your descriptions are very clear and helpful. Thanks!!
Thank you, however as mention previously tutorial is not done yet, I made some changes to database structure, deployed PeparedStatements plus some other things. All these require some post editing which I can not do now as I'm in process of finishing my MSc thesis. But on the end of October I should get back to it and finish it
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
Other Threads in the JSP Forum
- Previous Thread: Disabling text-wrapping for f:selectItem tags
- Next Thread: witch one is better Jboss server or tomcat server
| Thread Tools | Search this Thread |
Tag cloud for JSP
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient project read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write






