1 22 package org.jboss.resource.adapter.jdbc; 23 24 import java.io.Serializable ; 25 import java.sql.Connection ; 26 import java.sql.Statement ; 27 import java.sql.SQLException ; 28 29 35 public class CheckValidConnectionSQL 36 implements ValidConnectionChecker, Serializable 37 { 38 private static final long serialVersionUID = -222752863430216887L; 39 40 String sql; 41 42 public CheckValidConnectionSQL() 43 { 44 } 45 46 public CheckValidConnectionSQL(String sql) 47 { 48 this.sql = sql; 49 } 50 51 public SQLException isValidConnection(Connection c) 52 { 53 try 54 { 55 Statement s = c.createStatement(); 56 try 57 { 58 s.execute(sql); 59 return null; 60 } 61 finally 62 { 63 s.close(); 64 } 65 } 66 catch (SQLException e) 67 { 68 return e; 69 } 70 } 71 } 72 | Popular Tags |