Обсуждение: Connection String
/*
// 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;
}
--
RegardsRajeev Menon
EXCELLENCE IS MORE FUN THAN MEDIOCRITY!
--- 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