1 16 package com.ibatis.dao.client.template; 17 18 import com.ibatis.dao.client.DaoException; 19 import com.ibatis.dao.client.DaoManager; 20 import com.ibatis.dao.client.DaoTransaction; 21 import com.ibatis.dao.engine.transaction.ConnectionDaoTransaction; 22 23 import java.sql.Connection ; 24 25 33 public abstract class JdbcDaoTemplate extends DaoTemplate { 34 35 42 public JdbcDaoTemplate(DaoManager daoManager) { 43 super(daoManager); 44 } 45 46 52 protected Connection getConnection() { 53 DaoTransaction trans = daoManager.getTransaction(this); 54 if (!(trans instanceof ConnectionDaoTransaction)) { 55 throw new DaoException("The DAO manager of type " + daoManager.getClass().getName() + 56 " cannot supply a JDBC Connection for this template, and is therefore not" + 57 "supported by JdbcDaoTemplate."); 58 } 59 return ((ConnectionDaoTransaction) trans).getConnection(); 60 } 61 62 } 63 | Popular Tags |