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


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2005-2006, 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:        package org.geotools.data.hsql;
017:
018:        import java.io.PrintWriter;
019:        import java.sql.Connection;
020:        import java.sql.DriverManager;
021:        import java.sql.SQLException;
022:
023:        /**
024:         * Shell for JDBC transactions of all types. This provides a base class to the
025:         * database transactional classes.
026:         *
027:         * @author Amr Alam, Refractions Research
028:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/hsql/src/main/java/org/geotools/data/hsql/HsqlConnection.java $
029:         */
030:        public class HsqlConnection implements  javax.sql.DataSource {
031:            //private static Category _log = Category.getInstance(MysqlConnection.class.getName());
032:
033:            /** The Mysql-specific JDBC driver class using mm.mysql */
034:            private static final String HSQL_DRIVER_CLASS = "org.hsqldb.jdbcDriver";
035:
036:            /** The Mysql-specific JDBC driver path. */
037:            private static final String HSQL_DRIVER_PATH = "jdbc:hsql";
038:
039:            /** the computer where the database to connect to resides */
040:            private String host;
041:
042:            /** The port to connect on */
043:            private String port;
044:
045:            /** The name of the database to connect to */
046:            private String dbName;
047:
048:            /** The name of the user to log in to the database */
049:            private String user = null;
050:
051:            /** The password of the user to log in to the database */
052:            private String password = null;
053:
054:            /**
055:             * Constructor with all internal database driver classes, driver paths and
056:             * database types.
057:             *
058:             * @param host The driver class; should be passed from the
059:             *        database-specific subclass.
060:             * @param port The driver path; should be passed from the database-specific
061:             *        subclass.
062:             * @param dbName The database type; should be passed from the
063:             *        database-specific subclass.
064:             */
065:            public HsqlConnection(String host, String port, String dbName) {
066:                this .host = host;
067:                this .port = port;
068:                this .dbName = dbName;
069:            }
070:
071:            /**
072:             * Sets the user and password strings of the login to be used when
073:             * connecting to the Mysql database.
074:             *
075:             * @param user The string of the user to connect to the database with.
076:             * @param password The string of the password of user.
077:             */
078:            public void setLogin(String user, String password) {
079:                this .user = user;
080:                this .password = password;
081:            }
082:
083:            /**
084:             * An accessor function to get the user to log in to the db.
085:             *
086:             * @return the user.
087:             */
088:            public String getLoginUser() {
089:                return user;
090:            }
091:
092:            /**
093:             * An accessor function to get the password to log in to the db.
094:             *
095:             * @return a string of the password.
096:             */
097:            public String getLoginPassword() {
098:                return password;
099:            }
100:
101:            /**
102:             * Retrieves a connection to the Mysql database, using the current user and
103:             * password;
104:             *
105:             * @return An open SQL connection with the database.
106:             *
107:             * @throws SQLException if there are any database problems.
108:             */
109:            public Connection getConnection() throws SQLException {
110:                return getConnection(user, password);
111:            }
112:
113:            /**
114:             * Retrieves a connection to the Mysql database, specifying a user and
115:             * password.
116:             *
117:             * @param user The string of the user to connect to the database with.
118:             * @param password The string of the corresponding password of user.
119:             *
120:             * @return An open SQL connection with the database.
121:             *
122:             * @throws SQLException if there are any database problems.
123:             */
124:            public Connection getConnection(String user, String password)
125:                    throws SQLException {
126:                // creates the string to connect with
127:                String connectionPath = HSQL_DRIVER_PATH + "://" + host + ":"
128:                        + port + "/" + dbName;
129:                Connection dbConnection = null;
130:
131:                // Instantiate the driver classes
132:                try {
133:                    Class.forName(HSQL_DRIVER_CLASS);
134:                    dbConnection = DriverManager.getConnection(connectionPath,
135:                            user, password);
136:                } catch (ClassNotFoundException e) {
137:                    throw new SQLException("Hsql driver was not found.");
138:                }
139:
140:                return dbConnection;
141:            }
142:
143:            /**
144:             * An accessor function to get the length of timeout.
145:             *
146:             * @return the time out.
147:             *
148:             * @task TODO: implement this.
149:             */
150:            public int getLoginTimeout() {
151:                return 10;
152:            }
153:
154:            /**
155:             * A setter function to get the length of timeout.
156:             *
157:             * @param seconds the length of the time out.
158:             *
159:             * @task TODO: implement this.
160:             */
161:            public void setLoginTimeout(int seconds) {
162:            }
163:
164:            /**
165:             * An accessor function to get the log writer.
166:             *
167:             * @return a writer
168:             *
169:             * @task TODO: implement this.
170:             */
171:            public PrintWriter getLogWriter() {
172:                return new PrintWriter(System.out);
173:            }
174:
175:            /**
176:             * An setter method to set the log writer.
177:             *
178:             * @param out the writer to use for logging.
179:             *
180:             * @task TODO: implement this.
181:             */
182:            public void setLogWriter(PrintWriter out) {
183:            }
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.