KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xalan > lib > sql > PooledConnection


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17  * $Id: PooledConnection.java,v 1.11 2004/02/11 17:56:36 minchau Exp $
18  */

19 package org.apache.xalan.lib.sql;
20
21 import java.sql.Connection JavaDoc;
22 import java.sql.SQLException JavaDoc;
23
24 /**
25  */

26 public class PooledConnection
27 {
28
29   // Real JDBC Connection
30
/**
31    */

32   private Connection JavaDoc connection = null;
33   // boolean flag used to determine if connection is in use
34
/**
35    */

36   private boolean inuse = false;
37
38   // Constructor that takes the passed in JDBC Connection
39
// and stores it in the connection attribute.
40
/**
41    * @param value
42    */

43   public PooledConnection( Connection JavaDoc value )
44   {
45     if ( value != null ) { connection = value; }
46   }
47
48   /**
49    * Returns a reference to the JDBC Connection
50    * @return Connection
51    */

52   public Connection JavaDoc getConnection( )
53   {
54     // get the JDBC Connection
55
return connection;
56   }
57
58   /**
59    * Set the status of the PooledConnection.
60    *
61    * @param value
62    *
63    */

64   public void setInUse( boolean value )
65   {
66     inuse = value;
67   }
68
69   /**
70    * Returns the current status of the PooledConnection.
71    *
72    */

73   public boolean inUse( ) { return inuse; }
74
75   /**
76    * Close the real JDBC Connection
77    *
78    */

79   public void close( )
80   {
81     try
82     {
83       connection.close();
84     }
85     catch (SQLException JavaDoc sqle)
86     {
87       System.err.println(sqle.getMessage());
88     }
89   }
90 }
91
Popular Tags