KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > utils > weblogic > WeblogicConnectionProvider


1 /*
2  * Copyright 2004-2005 OpenSymphony
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
15  *
16  */

17
18 /*
19  * Previously Copyright (c) 2001-2004 James House
20  */

21 package org.quartz.utils.weblogic;
22
23 import java.sql.Connection JavaDoc;
24 import java.sql.SQLException JavaDoc;
25
26 import org.quartz.utils.ConnectionProvider;
27
28 import weblogic.jdbc.jts.Driver;
29
30 /**
31  * <p>
32  * Provides connections via Weblogic's JTS driver.
33  * </p>
34  *
35  * @see org.quartz.utils.ConnectionProvider
36  * @see org.quartz.utils.DBConnectionManager
37  *
38  * @author Mohammad Rezaei
39  * @author James House
40  */

41 public class WeblogicConnectionProvider implements ConnectionProvider {
42
43     /*
44      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45      *
46      * Data members.
47      *
48      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49      */

50
51     private String JavaDoc poolName;
52
53     private weblogic.jdbc.jts.Driver driver;
54
55     /*
56      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57      *
58      * Constructors.
59      *
60      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61      */

62
63     public WeblogicConnectionProvider(String JavaDoc poolName) {
64         this.poolName = poolName;
65     }
66
67     /*
68      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69      *
70      * Interface.
71      *
72      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73      */

74
75     public Connection JavaDoc getConnection() throws SQLException JavaDoc {
76         try {
77             if (driver == null) {
78                 driver = (Driver)weblogic.jdbc.jts.Driver.class.newInstance();
79             }
80
81             java.sql.Connection JavaDoc con = null;
82             con = driver.connect("jdbc:weblogic:jts:" + poolName,
83                     (java.util.Properties JavaDoc) null);
84
85             return con;
86         } catch (Exception JavaDoc e) {
87             throw new SQLException JavaDoc(
88                     "Could not get weblogic pool connection with name '"
89                             + poolName + "': " + e.getClass().getName() + ": "
90                             + e.getMessage());
91         }
92     }
93     
94     public void shutdown() throws SQLException JavaDoc {
95         // do nothing
96
}
97 }
98
Popular Tags