| | |
How to Connect MySQL from JSP Page
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 36
Reputation:
Solved Threads: 4
There is nothing wrong by putting the database connection in the JSP, but you have to create a new database connection and query for every page you creates. This will reduse the performance and response on server. This is one of the problems. Instead you could create a connection class and put it into application scope and the connection will be made when server is started. This is done only once. Then it is available for all objects that uses table info from the database.
Last edited by electron33; May 29th, 2008 at 8:28 pm.
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
•
•
Join Date: Jan 2008
Posts: 36
Reputation:
Solved Threads: 4
MVC (Model View Controller) That is Model this part holds the data between view and database or files, View this is the JSP, GUI or other interface presentet to the user, Controller this is the part that sends the messages of what to do with the data when user clicks a component or some changes happens on the database table. Please read more about this topic at SUN's pages.
1
#36 Oct 27th, 2009
•
•
•
•
There is nothing wrong by putting the database connection in the JSP,
•
•
•
•
but you have to create a new database connection and query for every page you creates.
•
•
•
•
This will reduse the performance and response on server. This is one of the problems.
•
•
•
•
Instead you could create a connection class and put it into application scope and the connection will be made when server is started. This is done only once. Then it is available for all objects that uses table info from the database.
Connection Pools, Beans, and a properly implemented layered approach. Everything presented here is ....... well, I don't think I really need to say it.
Last edited by masijade; Oct 27th, 2009 at 5:42 pm.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- How to connect Oracle database from JSP page (Java)
- Very Very Urgent...Need Code for Calculating Execution Time For Jsp Page (JSP)
- Inserting uft8 strings into MySQL from jsp page (JSP)
- how to connect oracle 8i database with jsp page (JSP)
- Dynamic links in JSP page-need help (JSP)
- how to call javabean from jsp page upon onChange event (JSP)
- setting up MyODBC to connect to MySQL, need help.... (MySQL)
- I think I'm going to cry... (JSP)
Other Threads in the JSP Forum
- Previous Thread: Unable to connect to tomcat through browser
- Next Thread: MVC help
Views: 22259 | Replies: 35
| 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






