public class TestMyConnection {
@Test
public void testInsert(){
Connection conn=null;
PreparedStatement pstmt=null;
try {
DataSource ds=new MyDataSource();
//从连接池中取 连接
conn=ds.getConnection();
System.out.println(conn.getClass().getName());
} catch (Exception e) {
throw new RuntimeException(e);
}finally{
if(null!=conn){
try {
conn.close();//释放连接
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
}
}