KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > smartlib > pool > test > SampleConnectionProviderImpl


1 package org.smartlib.pool.test;
2
3 import java.sql.*;
4 import org.smartlib.pool.core.*;
5 import javax.naming.*;
6 import javax.sql.*;
7
8 /**
9  * Never got a chance to compile this program
10  */

11
12 public class SampleConnectionProviderImpl implements ConnectionProvider {
13
14     
15     private DataSource dataSource = null;
16     
17     public SampleConnectionProviderImpl() throws Exception JavaDoc {
18
19         InitialContext ic = new InitialContext();
20         dataSource = (DataSource)ic.lookup("MyPool");
21         
22     }
23         
24
25     public Connection getConnection() throws Exception JavaDoc {
26
27         return dataSource.getConnection();
28
29     }
30
31     public void returnConnection(Connection conn) throws Exception JavaDoc {
32
33         conn.close();
34
35     }
36
37     
38
39 }
40
Popular Tags