You could manage the JDBC connection yourself or you could let your container take care of it for you. However this is dependent on the container you use. Here is how to do it in Tomcat:
http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#JDBC_Data_Sources In Java folks generally use a layered approach as can be seen in the Click examples, where you have separate packages for your services and pages. Other prefer to package by feature where each feature is placed in it's own package and will include the Page and Service. So depending on how you build your app will determine where your JDBC code lives. When using JDBC directly the code will live in a special layer just for Database access, often called a DAO layer. But nothing stops you from simply grabbing the JDBC connection in your Page and making database calls from there. Kind regards Bob On 13/01/2011 14:21, Schultz, Gary T - COMMERCE wrote: > I've worked with JDBC and last programmed in Java about six years ago. > > Concerning the Click data connection. After getting the JDBC connection > established in Click application context.xml and web.xml, can I simply call > the data connection in a Click page class and if so how is that done? Or is > it more complicated? > > - Gary > > ________________________________________ > From: Bob Schellink [[email protected]] > Sent: Wednesday, January 12, 2011 6:03 PM > To: [email protected] > Subject: Re: Database connection > > Hi Gary, > > ORMs are sophisticated tools and while they are great tools in enterprise > environments, they have > steep learning curves. There are many other ORMs besides Cayenne, including > Hibernate and the > standard Java Persistence API or JPA for short. > > There are also simpler database tools like MyBatis which is more of a > database mapping tool than a > full blown ORM. > > While Click examples uses Cayenne you could always use straight JDBC which is > more low level. > > WRT how this is done, there is a Cayenne DataContextFilter defined in web.xml > which bootstraps the > environment. Cayenne has a modeler where you define your DB connection and > Cayenne manage these > connections for you. Once the DataContext is defined you use it to perform > CRUD operations using > your domain objects. > > Having a background in PHP myself I'd say that Java is heavily geared towards > enterprise and you > will find it "heavier" than the scripting environment of PHP. > > Kind regards > > Bob > > On 13/01/2011 10:40, Schultz, Gary T - COMMERCE wrote: >> I'm starting work on an application. Normally I would use PHP, but I >> accidently found Apache Click. >> Looking at the documentation and examples, it appears easy to use. Maybe I >> missed it in the >> documentation, but how do you get data stored in a database? >> >> In a separate email exchange I received a reply from Malcolm Edgar saying >> the examples use Apache >> Cayenne ORM framework. Is there an example that elaborates on how this is >> done? I've never worked >> with a ORM framework, is the learning curve steep? Any other ORM Frameworks >> worth looking at? >> >> Sincerely, >> >> Gary Schultz >> Web Administrator/Developer >> Wisconsin Department of Commerce >> >> ---------------------------------------------------------------------------------------------------- >> CONFIDENTIALITY NOTICE: This electronic mail transmission and any >> accompanying documents may contain >> confidential and legally privileged information. If you are not the intended >> recipient, you are >> strictly prohibited from any disclosure, copying, distribution, or storage >> of the contents of the >> information contained in the transmission. If you have received this >> transmission in error, please >> notify the sender and delete the message. Thank you. > > > CONFIDENTIALITY NOTICE: This electronic mail transmission and any > accompanying documents may contain confidential and legally privileged > information. If you are not the intended recipient, you are strictly > prohibited from any disclosure, copying, distribution, or storage of the > contents of the information contained in the transmission. If you have > received this transmission in error, please notify the sender and delete the > message. Thank you. >
