Source Code Cross Referenced for ConnectionPoolFacade.java in  » GIS » GeoTools-2.4.1 » org » geotools » data » geometryless » 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 » GIS » GeoTools 2.4.1 » org.geotools.data.geometryless 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    Geotools2 - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2002, Geotools Project Managment Committee (PMC)
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         *
016:         */
017:        package org.geotools.data.geometryless;
018:
019:        import java.sql.SQLException;
020:        import java.util.logging.Logger;
021:
022:        import javax.sql.ConnectionPoolDataSource;
023:        import javax.sql.PooledConnection;
024:
025:        /**
026:         * Creates ConnectionPool objects for a certain JDBC database instance.
027:         * 
028:         * @author Rob Atkinson rob@socialchange.net.NOSPAM.au
029:         * @author Gary Sheppard garysheppard@psu.edu
030:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/geometryless/src/main/java/org/geotools/data/geometryless/ConnectionPoolFacade.java $
031:         */
032:        public class ConnectionPoolFacade implements  ConnectionPoolDataSource {
033:
034:            /** Standard logging instance */
035:            private static final Logger LOGGER = org.geotools.util.logging.Logging
036:                    .getLogger("org.geotools.data.geometryless");
037:
038:            private ConnectionPoolDataSource _nativePool;
039:
040:            /** Creates configuration-driven JDBC driver class. */
041:
042:            private String _dbURL;
043:
044:            private String _username = "";
045:
046:            private String _password = "";
047:
048:            /**
049:             * Creates a new ConnectionPool object from a specified database URL. This
050:             * is normally of the following format: <br/><br/>jdbc:mysql:// <host>:
051:             * <port>/ <instance>
052:             * 
053:             * @param url
054:             *            the JDBC database URL
055:             */
056:            public ConnectionPoolFacade(String poolKey, String driver)
057:                    throws SQLException {
058:
059:                try {
060:                    _nativePool = (ConnectionPoolDataSource) (Class
061:                            .forName(driver).newInstance());
062:                    // LOGGER.fine("Obtained ConnectionPoolDataSource " + _nativePool
063:                    //		+ " from driver " + driver);
064:
065:                } catch (Exception e) {
066:                    throw new SQLException(
067:                            "Failed to instantiate connection pool using "
068:                                    + driver + "(" + e + ")");
069:                }
070:            }
071:
072:            /**
073:             * Sets the JDBC database login credentials.
074:             * 
075:             * @param username
076:             *            the username
077:             *  
078:             */
079:            public void setUser(String username) {
080:                _username = username;
081:
082:            }
083:
084:            /**
085:             * Sets the JDBC database login credentials.
086:             * 
087:             * @param username
088:             *            the username
089:             * @param password
090:             *            the password
091:             */
092:            public void setURL(String dbURL) throws SQLException {
093:
094:                _dbURL = dbURL;
095:
096:                try {
097:
098:                    _nativePool.getClass().getMethod("setURL",
099:                            new Class[] { String.class }).invoke(_nativePool,
100:                            new Object[] { _dbURL });
101:                } catch (Exception e) {
102:
103:                    LOGGER
104:                            .severe("Failed to instantiate connection pool trying setURL method with value "
105:                                    + _dbURL);
106:                    LOGGER
107:                            .severe("Either the info.xml urlprefix is incorrect, or you need to use an org.geotools.data.geometryless.wrapper class,");
108:                    LOGGER
109:                            .severe("or you need to wrapper your driver to provide a setURL method");
110:
111:                    throw new SQLException(
112:                            "Failed to instantiate connection pool using "
113:                                    + _dbURL + "(" + e + ")");
114:                }
115:
116:                LOGGER.fine("Instantiated connection pool using " + _dbURL);
117:            }
118:
119:            /**
120:             * Sets the JDBC database login credentials.
121:             * 
122:             * @param username
123:             *            the username
124:             * @param password
125:             *            the password
126:             */
127:            public void setPassword(String password) {
128:
129:                _password = password;
130:            }
131:
132:            public PooledConnection getPooledConnection() throws SQLException {
133:
134:                return getPooledConnection(_username, _password);
135:            }
136:
137:            /* these are all the methods needed for the interface... */
138:
139:            public PooledConnection getPooledConnection(String user,
140:                    String password) throws SQLException {
141:
142:                return _nativePool.getPooledConnection(user, password);
143:            }
144:
145:            public int getLoginTimeout() throws SQLException {
146:                return _nativePool.getLoginTimeout();
147:            }
148:
149:            public java.io.PrintWriter getLogWriter() throws SQLException {
150:                return _nativePool.getLogWriter();
151:            }
152:
153:            public void setLogWriter(java.io.PrintWriter out)
154:                    throws SQLException {
155:                _nativePool.setLogWriter(out);
156:            }
157:
158:            public void setLoginTimeout(int seconds) throws SQLException {
159:                _nativePool.setLoginTimeout(seconds);
160:            }
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.