In my project i have more than 30 JSP pages and for every page i have to connect to database...(some time there is a chance that i may change databases). and i dont want to touch my Business logic, can any one plz give me some coding so that i can write jdbc code once and retrive.
(i know there is some way where we will give class.forname & drivers manager path in Web.xml, if any one know's this plz give me code)
Thnx....in advance
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35256
7
posted
0
First off, keeping database code in JSPs is considered bad design - move any DB access code to Java code, e.g. a backing bean or a servlet. This page of the Tomcat documentation outlines how you can configure and use a connection pool in Tomcat.
You got to give more details like webserver/application server details, database make,ear/war application etc.
Bascially,What you need to do is configure a connection pool and bind it to a Datasource for the specific database, and access it using JNDI in your code.