KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > logicalcobwebs > proxool > VirtoolDriver


1 /*
2  * This software is released under a licence similar to the Apache Software Licence.
3  * See org.logicalcobwebs.proxool.package.html for details.
4  * The latest version is available at http://proxool.sourceforge.net
5  */

6 package org.logicalcobwebs.proxool;
7
8 import java.sql.Connection JavaDoc;
9 import java.sql.Driver JavaDoc;
10 import java.sql.DriverManager JavaDoc;
11 import java.sql.DriverPropertyInfo JavaDoc;
12 import java.sql.SQLException JavaDoc;
13 import java.util.Properties JavaDoc;
14
15 /**
16  * This class acts as a virtual pool. When you ask it for a connection it
17  * delegates to one of the designated real pools. Some assumptions:
18  *
19  * Getting a connection needs to be very fast.
20  *
21  * Switching pools can be relatively slow (but just to get that in perspective,
22  * > 100ms)
23  *
24  * We should detect pools that don't respond (timeout), throw certain
25  * SQLExceptions, or are unacceptably slow.
26  *
27  * We should also allow simple load balancing between pools that are
28  * up.
29  *
30  * @version $Revision: 1.2 $, $Date: 2003/03/03 11:12:02 $
31  * @author Bill Horsman (bill@logicalcobwebs.co.uk)
32  * @author $Author: billhorsman $ (current maintainer)
33  * @since Proxool 0.5
34  */

35 public class VirtoolDriver implements Driver JavaDoc {
36
37     private static final String JavaDoc VIRTOOL = "virtool";
38
39     private String JavaDoc[] activePools;
40
41     private int nextPool;
42
43     public Connection JavaDoc connect(String JavaDoc url, Properties JavaDoc info)
44             throws SQLException JavaDoc {
45         String JavaDoc alias = activePools[nextPool];
46
47         // Now we need to move to the next pool. This code isn't ThreadSafe and
48
// we don't want to make it so because it would have a performance
49
// impact.
50

51         return null;
52     }
53
54     public boolean acceptsURL(String JavaDoc url) throws SQLException JavaDoc {
55         return (url.startsWith(VIRTOOL));
56     }
57
58     public DriverPropertyInfo JavaDoc[] getPropertyInfo(String JavaDoc url, Properties JavaDoc info)
59             throws SQLException JavaDoc {
60         return new DriverPropertyInfo JavaDoc[0];
61     }
62
63     public int getMajorVersion() {
64         throw new UnsupportedOperationException JavaDoc("This virtual driver doesn't support this operation.");
65     }
66
67     public int getMinorVersion() {
68         throw new UnsupportedOperationException JavaDoc("This virtual driver doesn't support this operation.");
69     }
70
71     public boolean jdbcCompliant() {
72         throw new UnsupportedOperationException JavaDoc("This virtual driver doesn't support this operation.");
73     }
74
75     static {
76         try {
77             DriverManager.registerDriver(new VirtoolDriver());
78         } catch (SQLException JavaDoc e) {
79             System.out.println(e.toString());
80         }
81     }
82
83 }
84
85 /*
86  Revision history:
87  $Log: VirtoolDriver.java,v $
88  Revision 1.2 2003/03/03 11:12:02 billhorsman
89  fixed licence
90
91  Revision 1.1 2002/12/15 19:00:32 chr32
92  Moved over from 'ext' source tree.
93
94  Revision 1.3 2002/11/12 20:19:18 billhorsman
95  added some doc
96
97  Revision 1.2 2002/10/27 13:05:01 billhorsman
98  checkstyle
99
100  Revision 1.1 2002/10/27 12:05:39 billhorsman
101  early, early draft
102
103 */

104
Popular Tags