Skip site navigation (1) Skip section navigation (2)

Re: Totally weird behaviour in org.postgresql.Driver

From: "Peter" <peter(at)greatnowhere(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Totally weird behaviour in org.postgresql.Driver
Date: 2009-03-13 09:27:44
Message-ID: 49ba2711$0$1341$834e42db@reader.greatnowhere.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
> Couple things.... do you really need to synchronize twice in every method
> ???
> Have you looked at dbcp or c3po instead of re-inventing the wheel ?
>
> Can you supply us with a test case which does exhibit the bug ?

I'm fairly sure this is JVM/Tomcat bug I'm dealing with here. The test case 
below was configured to run on every request received by servlet, but only 
started exhibiting the weird behaviour after few hours of heavy load:


import java.sql.*;
import java.util.logging.Logger;

import org.postgresql.ds.PGSimpleDataSource;

public class PGTester {

 public static void main() {

  org.postgresql.ds.PGSimpleDataSource _ds=new 
org.postgresql.ds.PGSimpleDataSource();
  _ds.setDatabaseName("mydb");
  _ds.setServerName("myhost");
  _ds.setPortNumber(5432);

  for (int i=0; i<20; i++) {
   Connector con = new Connector(i+1,_ds);
   new Thread(con, "Conn" ).start();
  }
 }

 private static class Connector implements Runnable {
  @SuppressWarnings("unused")
  private int _num;
  private PGSimpleDataSource _ds;

  Connector(int n, PGSimpleDataSource ds) {
   _num = n;
   _ds = ds;
  }

  public void run() {
   for (int i=0; i<100; i++) {
    try {
     Connection conn = _ds.getConnection("user","pass");
     // System.out.println("Connector " + _num + " made connection #" + 
(i+1));
     conn.close();
    } catch (Exception e) {
     Logger.getLogger(this.getClass().getName()).severe(e.getMessage());
    }
   }
  }
 }

}






In response to

pgsql-jdbc by date

Next:From: Roland RobertsDate: 2009-03-13 16:45:07
Subject: ResultSet.getTimestamp(Calendar) off by one-hour
Previous:From: Kris JurkaDate: 2009-03-13 04:50:18
Subject: Re: Renaming sequence auto generated by SERIAL type don't update pg_attrdef

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group