1 22 23 package org.jboss.resource.adapter.jdbc.vendor; 24 25 import java.io.Serializable ; 26 import java.sql.Connection ; 27 import java.sql.SQLException ; 28 import java.sql.Statement ; 29 30 import org.jboss.resource.adapter.jdbc.ValidConnectionChecker; 31 32 38 public class PostgreSQLValidConnectionChecker implements ValidConnectionChecker, Serializable 39 { 40 41 42 private static final long serialVersionUID = 4867167301823753925L; 43 44 public SQLException isValidConnection(Connection c) 45 { 46 47 Statement stmt = null; 48 SQLException sqe = null; 49 50 try 51 { 52 stmt = c.createStatement(); 53 stmt.execute(""); 54 55 } 56 57 catch (Exception e) 58 { 59 if (e instanceof SQLException ) 60 { 61 sqe = (SQLException )e; 62 63 } 64 65 } 66 finally 67 { 68 if (stmt != null) 69 { 70 71 try 72 { 73 stmt.close(); 74 } 75 catch (SQLException e) 76 { 77 } 78 79 } 80 } 81 82 return sqe; 83 } 84 85 } 86 | Popular Tags |