diff -rc postgresql-jdbc-8.3-603.src.orig/org/postgresql/core/v2/ConnectionFactoryImpl.java postgresql-jdbc-8.3-603.src/org/postgresql/core/v2/ConnectionFactoryImpl.java
*** postgresql-jdbc-8.3-603.src.orig/org/postgresql/core/v2/ConnectionFactoryImpl.java	2008-01-07 23:56:27.000000000 -0700
--- postgresql-jdbc-8.3-603.src/org/postgresql/core/v2/ConnectionFactoryImpl.java	2008-04-09 10:33:00.000000000 -0700
***************
*** 68,73 ****
--- 68,86 ----
              // Construct and send an ssl startup packet if requested.
              if (trySSL)
                  newStream = enableSSL(newStream, requireSSL, info, logger);
+             
+             
+             // Set the socket timeout if the "socketTimeout" property has been set.
+             String socketTimeoutProperty = info.getProperty("socketTimeout", "0");
+             try {
+                 int socketTimeout = Integer.parseInt(socketTimeoutProperty);
+                 if (socketTimeout > 0) {
+                     newStream.getSocket().setSoTimeout(socketTimeout*1000);
+                 }
+             } catch (NumberFormatException nfe) {
+                 logger.info("Couldn't parse socketTimeout value:" + socketTimeoutProperty);
+             }
+ 
  
              // Construct and send a startup packet.
              sendStartupPacket(newStream, user, database, logger);
diff -rc postgresql-jdbc-8.3-603.src.orig/org/postgresql/core/v3/ConnectionFactoryImpl.java postgresql-jdbc-8.3-603.src/org/postgresql/core/v3/ConnectionFactoryImpl.java
*** postgresql-jdbc-8.3-603.src.orig/org/postgresql/core/v3/ConnectionFactoryImpl.java	2008-01-07 23:56:27.000000000 -0700
--- postgresql-jdbc-8.3-603.src/org/postgresql/core/v3/ConnectionFactoryImpl.java	2008-04-09 10:33:00.000000000 -0700
***************
*** 79,84 ****
--- 79,95 ----
              // Construct and send an ssl startup packet if requested.
              if (trySSL)
                  newStream = enableSSL(newStream, requireSSL, info, logger);
+             
+             // Set the socket timeout if the "socketTimeout" property has been set.
+             String socketTimeoutProperty = info.getProperty("socketTimeout", "0");
+             try {
+                 int socketTimeout = Integer.parseInt(socketTimeoutProperty);
+                 if (socketTimeout > 0) {
+                     newStream.getSocket().setSoTimeout(socketTimeout*1000);
+                 }
+             } catch (NumberFormatException nfe) {
+                 logger.info("Couldn't parse socketTimeout value:" + socketTimeoutProperty);
+             }
  
              // Construct and send a startup packet.
              String[][] params = {
diff -rc postgresql-jdbc-8.3-603.src.orig/org/postgresql/ds/common/BaseDataSource.java postgresql-jdbc-8.3-603.src/org/postgresql/ds/common/BaseDataSource.java
*** postgresql-jdbc-8.3-603.src.orig/org/postgresql/ds/common/BaseDataSource.java	2008-01-07 23:56:27.000000000 -0700
--- postgresql-jdbc-8.3-603.src/org/postgresql/ds/common/BaseDataSource.java	2008-04-09 10:33:00.000000000 -0700
***************
*** 49,57 ****
--- 49,59 ----
      private int portNumber;
      private int prepareThreshold;
      private int loginTimeout; // in seconds
+     private int socketTimeout; // in seconds
      private boolean ssl = false;
      private String sslfactory;
  
+     
      /**
       * Gets a connection to the PostgreSQL database.  The database is identified by the
       * DataSource properties serverName, databaseName, and portNumber. The user to
***************
*** 263,268 ****
--- 265,287 ----
      }
  
      /**
+      * Sets the socket timeout (SOTimeout), in seconds 
+      */
+     public void setSocketTimeout(int seconds)
+     {
+         this.socketTimeout = seconds;
+     }
+     
+     /**
+      * @return the socket timeout (SOTimeout), in seconds
+      */
+     public int getSocketTimeout() 
+     {
+         return this.socketTimeout;
+     }
+ 
+ 
+     /**
       * Set whether the connection will be SSL encrypted or not.
       *
       * @param enabled if <CODE>true</CODE>, connect with SSL.
***************
*** 316,321 ****
--- 335,341 ----
          }
          sb.append("/").append(databaseName);
          sb.append("?loginTimeout=").append(loginTimeout);
+         sb.append("&socketTimeout=").append(socketTimeout);
          sb.append("&prepareThreshold=").append(prepareThreshold);
          if (ssl) {
              sb.append("&ssl=true");
***************
*** 357,362 ****
--- 377,383 ----
          
          ref.add(new StringRefAddr("prepareThreshold", Integer.toString(prepareThreshold)));
          ref.add(new StringRefAddr("loginTimeout", Integer.toString(loginTimeout)));
+         ref.add(new StringRefAddr("socketTimeout", Integer.toString(socketTimeout)));
          return ref;
      }
  
***************
*** 369,374 ****
--- 390,396 ----
          out.writeInt(portNumber);
          out.writeInt(prepareThreshold);
          out.writeInt(loginTimeout);
+         out.writeInt(socketTimeout);
      }
  
      protected void readBaseObject(ObjectInputStream in) throws IOException, ClassNotFoundException
***************
*** 380,385 ****
--- 402,408 ----
          portNumber = in.readInt();
          prepareThreshold = in.readInt();
          loginTimeout = in.readInt();
+         socketTimeout = in.readInt();
      }
  
  }
