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 DB2ValidConnectionChecker implements ValidConnectionChecker, Serializable 39 { 40 41 private static final long serialVersionUID = -1256537245822198702L; 42 43 44 private static final String VALID_QUERY = "SELECT CURRENT TIMESTAMP FROM SYSIBM.SYSDUMMY1"; 45 46 public SQLException isValidConnection(final Connection c) 47 { 48 SQLException theResult = null; 49 Statement s = null; 50 51 try 52 { 53 54 s = c.createStatement(); 55 s.execute(VALID_QUERY); 56 57 } 58 catch (SQLException e) 59 { 60 61 theResult = e; 62 63 } 64 finally 65 { 66 67 try 68 { 69 70 if (s != null) 71 s.close(); 72 } 73 catch (SQLException e) 74 { 75 } 76 77 } 78 79 return theResult; 80 } 81 82 } 83 | Popular Tags |