001: /*
002: * This software is released under a licence similar to the Apache Software Licence.
003: * See org.logicalcobwebs.proxool.package.html for details.
004: * The latest version is available at http://proxool.sourceforge.net
005: */
006: package org.logicalcobwebs.proxool;
007:
008: import java.sql.Connection;
009: import java.sql.Driver;
010: import java.sql.DriverManager;
011: import java.sql.DriverPropertyInfo;
012: import java.sql.SQLException;
013: import java.util.Properties;
014:
015: /**
016: * This class acts as a virtual pool. When you ask it for a connection it
017: * delegates to one of the designated real pools. Some assumptions:
018: *
019: * Getting a connection needs to be very fast.
020: *
021: * Switching pools can be relatively slow (but just to get that in perspective,
022: * > 100ms)
023: *
024: * We should detect pools that don't respond (timeout), throw certain
025: * SQLExceptions, or are unacceptably slow.
026: *
027: * We should also allow simple load balancing between pools that are
028: * up.
029: *
030: * @version $Revision: 1.2 $, $Date: 2003/03/03 11:12:02 $
031: * @author Bill Horsman (bill@logicalcobwebs.co.uk)
032: * @author $Author: billhorsman $ (current maintainer)
033: * @since Proxool 0.5
034: */
035: public class VirtoolDriver implements Driver {
036:
037: private static final String VIRTOOL = "virtool";
038:
039: private String[] activePools;
040:
041: private int nextPool;
042:
043: public Connection connect(String url, Properties info)
044: throws SQLException {
045: String alias = activePools[nextPool];
046:
047: // Now we need to move to the next pool. This code isn't ThreadSafe and
048: // we don't want to make it so because it would have a performance
049: // impact.
050:
051: return null;
052: }
053:
054: public boolean acceptsURL(String url) throws SQLException {
055: return (url.startsWith(VIRTOOL));
056: }
057:
058: public DriverPropertyInfo[] getPropertyInfo(String url,
059: Properties info) throws SQLException {
060: return new DriverPropertyInfo[0];
061: }
062:
063: public int getMajorVersion() {
064: throw new UnsupportedOperationException(
065: "This virtual driver doesn't support this operation.");
066: }
067:
068: public int getMinorVersion() {
069: throw new UnsupportedOperationException(
070: "This virtual driver doesn't support this operation.");
071: }
072:
073: public boolean jdbcCompliant() {
074: throw new UnsupportedOperationException(
075: "This virtual driver doesn't support this operation.");
076: }
077:
078: static {
079: try {
080: DriverManager.registerDriver(new VirtoolDriver());
081: } catch (SQLException e) {
082: System.out.println(e.toString());
083: }
084: }
085:
086: }
087:
088: /*
089: Revision history:
090: $Log: VirtoolDriver.java,v $
091: Revision 1.2 2003/03/03 11:12:02 billhorsman
092: fixed licence
093:
094: Revision 1.1 2002/12/15 19:00:32 chr32
095: Moved over from 'ext' source tree.
096:
097: Revision 1.3 2002/11/12 20:19:18 billhorsman
098: added some doc
099:
100: Revision 1.2 2002/10/27 13:05:01 billhorsman
101: checkstyle
102:
103: Revision 1.1 2002/10/27 12:05:39 billhorsman
104: early, early draft
105:
106: */
|