Source Code Cross Referenced for SimpoolAdapter.java in  » Database-JDBC-Connection-Pool » proxool » org » logicalcobwebs » proxool » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » proxool » org.logicalcobwebs.proxool 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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 org.logicalcobwebs.dbscript.ConnectionAdapterIF;
009:        import org.apache.commons.logging.Log;
010:        import org.apache.commons.logging.LogFactory;
011:
012:        import java.sql.Connection;
013:        import java.sql.DriverManager;
014:        import java.sql.SQLException;
015:        import java.util.Properties;
016:
017:        /**
018:         * This is the simplest pool you can get. It isn\ufffdt thread safe. It isn't robust.
019:         * But it is fast. We use it as our bench mark on how could we should strive
020:         * to be.
021:         *
022:         * Provides Simpool connections to the {@link org.logicalcobwebs.dbscript.ScriptFacade ScriptFacade}
023:         *
024:         * @version $Revision: 1.12 $, $Date: 2006/01/18 14:40:06 $
025:         * @author Bill Horsman (bill@logicalcobwebs.co.uk)
026:         * @author $Author: billhorsman $ (current maintainer)
027:         * @since Proxool 0.5
028:         */
029:        public class SimpoolAdapter implements  ConnectionAdapterIF {
030:
031:            private static final Log LOG = LogFactory
032:                    .getLog(SimpoolAdapter.class);
033:
034:            private Connection[] connections;
035:
036:            private int index = 0;
037:
038:            public String getName() {
039:                return "simpool";
040:            }
041:
042:            public void setup(String driver, String url, Properties info)
043:                    throws SQLException {
044:
045:                try {
046:                    Class.forName(driver);
047:                } catch (ClassNotFoundException e) {
048:                    throw new SQLException("Couldn't find " + driver);
049:                }
050:
051:                int connectionCount = Integer
052:                        .parseInt(info
053:                                .getProperty(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY));
054:                connections = new Connection[connectionCount];
055:                for (int i = 0; i < connectionCount; i++) {
056:                    connections[i] = DriverManager.getConnection(url, info);
057:                }
058:            }
059:
060:            public Connection getConnection() throws SQLException {
061:                Connection c = connections[index];
062:                index++;
063:                if (index >= connections.length) {
064:                    index = 0;
065:                }
066:                return c;
067:            }
068:
069:            public void closeConnection(Connection connection) {
070:                // Do nothing !
071:            }
072:
073:            public void tearDown() {
074:                try {
075:                    for (int i = 0; i < connections.length; i++) {
076:                        connections[i].close();
077:                    }
078:                } catch (SQLException e) {
079:                    LOG.error("Problem tearing down " + getName() + " adapter",
080:                            e);
081:                }
082:            }
083:
084:        }
085:
086:        /*
087:         Revision history:
088:         $Log: SimpoolAdapter.java,v $
089:         Revision 1.12  2006/01/18 14:40:06  billhorsman
090:         Unbundled Jakarta's Commons Logging.
091:
092:         Revision 1.11  2003/03/04 10:24:40  billhorsman
093:         removed try blocks around each test
094:
095:         Revision 1.10  2003/03/03 11:12:05  billhorsman
096:         fixed licence
097:
098:         Revision 1.9  2003/03/01 15:27:24  billhorsman
099:         checkstyle
100:
101:         Revision 1.8  2003/02/19 15:14:25  billhorsman
102:         fixed copyright (copy and paste error,
103:         not copyright change)
104:
105:         Revision 1.7  2003/02/06 17:41:03  billhorsman
106:         now uses imported logging
107:
108:         Revision 1.6  2003/01/27 23:32:10  billhorsman
109:         encoding fix (no idea how that happened)
110:
111:         Revision 1.5  2002/11/13 20:23:38  billhorsman
112:         change method name, throw exceptions differently, trivial changes
113:
114:         Revision 1.4  2002/11/09 16:02:20  billhorsman
115:         fix doc
116:
117:         Revision 1.3  2002/11/02 14:22:16  billhorsman
118:         Documentation
119:
120:         Revision 1.2  2002/11/02 12:46:42  billhorsman
121:         improved debug
122:
123:         Revision 1.1  2002/11/02 11:37:48  billhorsman
124:         New tests
125:
126:         Revision 1.1  2002/10/30 21:17:50  billhorsman
127:         new performance tests
128:
129:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.