pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
setting & using connection pool in beans for tomcat.
3+ messages / 2 participants
[nested] [flat]

* setting & using connection pool in beans for tomcat.
@ 2005-12-16 10:10  Simon Moses <ks_moses@yahoo.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Simon Moses @ 2005-12-16 10:10 UTC (permalink / raw)
  To: pgsql-jdbc

 dear sir,
 
 i have set connection pooling in tomcat. now i can use connections from that pool in jsp. 
 
 but i want all database accessing code in beans not in jsp. how to do it?
 
 i want to write a class(CPCon.java) with methods like 
 {
     void ConnectionPoolOpen(){}
     Connection getConnection(){}
     void closeConnection(){}
 ....
 }
 
 and call this class in all jsp pages with useBean tag. 
 
 if i write like this, is the connection pool is going to be used by all jsp pages for all tomcat server clients?
 
 if not how to do this?
 
 i am using tomcat 5.0. j2se1.4 and postgresql 8.0 with postgresql-8.0-312.jdbc3.jar driver.
 
 regards,
 Simon Moses.
 
 


**************************
Visit My Home Page
http://www.geocities.com/ks_moses
updated: 28 Sep 2004.
Simon Moses
**************************
__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: setting & using connection pool in beans for tomcat.
@ 2005-12-16 11:06  Dave Cramer <pg@fastcrypt.com>
  parent: Simon Moses <ks_moses@yahoo.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Dave Cramer @ 2005-12-16 11:06 UTC (permalink / raw)
  To: Simon Moses <ks_moses@yahoo.com>; +Cc: pgsql-jdbc

Simon,

Have you looked at

http://jdbc.postgresql.org/documentation/head/tomcat.html

Dave
On 16-Dec-05, at 5:10 AM, Simon Moses wrote:

>  dear sir,
>
> i have set connection pooling in tomcat. now i can use connections  
> from that pool in jsp.
>
> but i want all database accessing code in beans not in jsp. how to  
> do it?
>
> i want to write a class(CPCon.java) with methods like
> {
>     void ConnectionPoolOpen(){}
>     Connection getConnection(){}
>     void closeConnection(){}
> ....
> }
>
> and call this class in all jsp pages with useBean tag.
>
> if i write like this, is the connection pool is going to be used by  
> all jsp pages for all tomcat server clients?
>
> if not how to do this?
>
> i am using tomcat 5.0. j2se1.4 and postgresql 8.0 with  
> postgresql-8.0-312.jdbc3.jar driver.
>
> regards,
> Simon Moses.
>
>
>
> **************************
> Visit My Home Page
> http://www.geocities.com/ks_moses
> updated: 28 Sep 2004.
> Simon Moses
> **************************
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: setting & using connection pool in beans for tomcat.
@ 2005-12-17 05:35  Simon Moses <ks_moses@yahoo.com>
  parent: Dave Cramer <pg@fastcrypt.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Simon Moses @ 2005-12-17 05:35 UTC (permalink / raw)
  To: Dave Cramer <pg@fastcrypt.com>; +Cc: pgsql-jdbc

dear dave,
 
 i have set connection pooling in tomcat. with the sample code now i can connect to pool from jsp.
 
 the sample code given in that page is not connecting to my database. but same code in jsp is connecting.
 
 but i want to write a .java file which should hold the database connection(from tomcat connection pool) code and have a getConnection method. the one i am using now is
 
 <pre>
 
 package com.moses.srivaru;
 
 import java.sql.*;
 import java.io.*;
 
 public class DBCon{
     private Connection con = null;
 
     public DBCon(){
         try{
             String url = "jdbc:postgresql://localhost:5432/srivaru";
             Class.forName("org.postgresql.Driver");
             con = DriverManager.getConnection(url,"postgres","postgres");
         }catch(Exception e){System.out.println(e);}
     }
 
     public Connection getCon(){
         return con;
     }
 
     public void close(){
         try{
             con.close();
         }catch(Exception e){
             System.out.println(e);
         }
     }
 
 }
 
 </pre>
 
 this class is in tomcat_home/common/classes/com/moses/srivaru
 tell me where i should keep the new class which gives connection from tomcat connection pool.
 
 
 thanks for your reply,
 Simon Moses.
 

Dave Cramer <pg@fastcrypt.com> wrote: Simon,

Have you looked at

http://jdbc.postgresql.org/documentation/head/tomcat.html

Dave
On 16-Dec-05, at 5:10 AM, Simon Moses wrote:

>  dear sir,
>
> i have set connection pooling in tomcat. now i can use connections  
> from that pool in jsp.
>
> but i want all database accessing code in beans not in jsp. how to  
> do it?
>
> i want to write a class(CPCon.java) with methods like
> {
>     void ConnectionPoolOpen(){}
>     Connection getConnection(){}
>     void closeConnection(){}
> ....
> }
>
> and call this class in all jsp pages with useBean tag.
>
> if i write like this, is the connection pool is going to be used by  
> all jsp pages for all tomcat server clients?
>
> if not how to do this?
>
> i am using tomcat 5.0. j2se1.4 and postgresql 8.0 with  
> postgresql-8.0-312.jdbc3.jar driver.
>
> regards,
> Simon Moses.
>
>
>
> **************************
> Visit My Home Page
> http://www.geocities.com/ks_moses
> updated: 28 Sep 2004.
> Simon Moses
> **************************
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster




**************************
Visit My Home Page
http://www.geocities.com/ks_moses
updated: 28 Sep 2004.
Simon Moses
**************************
__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2005-12-17 05:35 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-12-16 10:10 setting & using connection pool in beans for tomcat. Simon Moses <ks_moses@yahoo.com>
2005-12-16 11:06 ` Dave Cramer <pg@fastcrypt.com>
2005-12-17 05:35   ` Simon Moses <ks_moses@yahoo.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox