I am wondering whether people develop a bean for making a database connection. I was thinking of creating of a bean that would return a Connection or Statement object and I came up with this java program but there is a problem when I try to include the bean in my jsp program.
java program...DbBean.java...placed in web-inf/classes/Utilities
Errors....taken from log file..
[ January 03, 2006: Message edited by: Raghavan Chockalingam ]
Raghavan, Can you make sure that the given error is thrown excatly the line :
Joined: Dec 20, 2005
Thanks both of you guys for your help and I did not know earlier that I should restart the server.
1. Is it always necessary to restart the server whenever there is a revision with the bean class?
2. I now have a logical problem, if the bean creates a Connection or a Statement object then how do I use those objects in the .jsp file???
For example.... <jsp:getProperty name="myConnection" property="stmt" />
the above statement gives a Statement object but how do I assign this object to a Statement object created in jsp scriptlet.
If you think I am totally wrong with the way I am thinking, can you tell me how do you establish/ use database connections in your applications. It would be very kind if you can me a working example of yours...thank you...
to 1) It is not necessary to restart the server if a class changes, but it is necessary to restart the web app that contains that class.
to 2) It is considered bad design to be using java.sql objects in a JSP page (and has practical drawbacks as well, like making exception handling hard). At a minimum, perform all the DB access in the bean class, and just retrieve the results from it in the JSP.