1 package org.jboss.resource.adapter.jdbc.vendor; 2 3 import java.io.Serializable ; 4 import java.sql.Connection ; 5 import java.sql.ResultSet ; 6 import java.sql.SQLException ; 7 import java.sql.Statement ; 8 9 import org.jboss.logging.Logger; 10 import org.jboss.resource.adapter.jdbc.ValidConnectionChecker; 11 12 18 public class SybaseValidConnectionChecker implements ValidConnectionChecker, Serializable 19 { 20 private static final Logger log = Logger.getLogger(SybaseValidConnectionChecker.class); 21 22 23 private static final long serialVersionUID = 4179707462244257791L; 24 25 26 private static final String VALID_QUERY = "SELECT getdate()"; 27 28 29 public SQLException isValidConnection(Connection c) 30 { 31 SQLException sqe = null; 32 Statement s = null; 33 ResultSet rs = null; 34 35 try 36 { 37 s = c.createStatement(); 38 rs = s.executeQuery(VALID_QUERY); 39 40 }catch (SQLException e) 41 { 42 43 sqe = e; 44 45 }finally 46 { 47 48 try 49 { 50 if(s != null) 51 { 52 s.close(); 53 54 } 55 } 56 57 catch (SQLException ignore) 58 { 59 log.warn("JDBC resource for " + this + " could not be closed"); 60 61 } 62 63 try 64 { 65 if(rs != null) 66 { 67 rs.close(); 68 } 69 } 70 71 catch (SQLException ignore) 72 { 73 log.warn("JDBC resource for " + this + " could not be closed"); 74 } 75 } 76 77 78 return sqe; 79 } 80 81 } 82 | Popular Tags |