pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Connection String
2+ messages / 2 participants
[nested] [flat]

* Connection String
@ 2006-03-08 08:24 Rajeev Menon <rajeev.menon.b@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Rajeev Menon @ 2006-03-08 08:24 UTC (permalink / raw)
  To: pgsql-jdbc

This is how i have coded the connection handler

******

/*
//      One Point Connection to the database.
//
*/
package beans;
import java.io.*;
import java.sql.*;

public final class ConnectionHandler
{
  static String url;
  static Connection con;
  static boolean isConnected;

  public static Connection getConnection ()
  {
         url="jdbc:postgresql://<ipaddress>:5432/<databasebname>";
    try
    {
      Class.forName("org.postgresql.Driver");
    }
    catch (ClassNotFoundException e)
    {
        System.out.println("Printing The Exception :");
        System.out.println (e);
        System.out.println("Printing The Stack Trace :");
        e.printStackTrace ();
    }
    try
    {
      System.out.println("****************B4
GETCONNECTION*********************************");

      con = DriverManager.getConnection (url,"root","");
      isConnected = true;
      System.out.println("****************AFTER
GETCONNECTION*********************************");

     catch (SQLException e)
    {
      System.out.println (e);
      e.printStackTrace ();
    }
    return con;
  }
*****
I'am using Tomcat.

The problem is that sometime the processing tends to slow down drastically
at this line "con = DriverManager.getConnection (url,"root","");" I know
this because when I see the catalina.out I can see the line
"****************B4 GETCONNECTION*********************************" and most
of the time the After Connection also come but occassionaly it just shows a
B4 connection line and waits and in the meantime as more and more users
login more and more B4 connections come up and suddenly the connecion is re
established. Could somone help because this is slowin down the system


--
RegardsRajeev Menon
EXCELLENCE IS MORE FUN THAN MEDIOCRITY!


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

* Re: Connection String
@ 2006-03-08 16:46 Nikola Milutinovic <alokin1@yahoo.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Nikola Milutinovic @ 2006-03-08 16:46 UTC (permalink / raw)
  To: pgsql-jdbc

--- Rajeev Menon <rajeev.menon.b@gmail.com> wrote:

> Hi,
> 
> Thanks for the reply.
> 
> I have been monitoring the connections and at any point there does not seem
> to be more than 15 connections open...i have seen the speed drop even when
> 2-3 connections are open.
> 
> 
> On 3/8/06, Nikola Milutinovic <alokin1@yahoo.com> wrote:
> >
> > --- Rajeev Menon <rajeev.menon.b@gmail.com> wrote:
> >
> > > of the time the After Connection also come but occassionaly it just
> > shows a
> > > B4 connection line and waits and in the meantime as more and more users
> > > login more and more B4 connections come up and suddenly the connecion is
> > re
> > > established. Could somone help because this is slowin down the system
> >
> > Could it be that you are not closing connections?
> >
> > There is always a limit as to how many connections can be opened on the
> > server,
> > configurable, of course, but finite. Connections that are left hanging
> > could
> > have a close-if-idle behaviour, I'm not sure. Usually people complain that
> > they
> > cannot access DB after a while, if they are leaking connections. Or
> > perhaps
> > you're just droping them and JVM's garbage collector is kicking in from
> > time to
> > time, closing GCed connections.
> >
> > I'd sugest setting up a connection pool, Tomcat's DBCP is very
> > configurable,
> > even in the sense of lost connections, see it's "idle*" parameters.
> >
> > How many connections do you have to the server, when the slowdown occurs?

This is puzzling. With such low connection count, I can see no good reason for
this delay. Is there anything in the server logs?

Nix.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



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


end of thread, other threads:[~2006-03-08 16:46 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-03-08 08:24 Connection String Rajeev Menon <rajeev.menon.b@gmail.com>
2006-03-08 16:46 Re: Connection String Nikola Milutinovic <alokin1@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