Source Code Cross Referenced for DummyDataSource.java in  » Rule-Engine » Mandarax » test » org » mandarax » zkb » 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 » Rule Engine » Mandarax » test.org.mandarax.zkb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:        package test.org.mandarax.zkb;
019:
020:        import java.io.PrintWriter;
021:        import java.sql.SQLException;
022:
023:        /**
024:         * "Simulation" of a data source, not functional but with some properties a real
025:         * implementaton probably has.
026:         * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
027:         * @version 3.4 <7 March 05>
028:         * @since 2.2
029:         */
030:        public class DummyDataSource implements  javax.sql.DataSource,
031:                java.io.Serializable {
032:
033:            private Class driver = null;
034:            private String connectString = "";
035:            private String userName = "";
036:            private String password = "";
037:            private int loginTimeout = 1000;
038:            private PrintWriter logWriter = null;
039:
040:            /**
041:             * Constructor.
042:             */
043:            public DummyDataSource() {
044:                super ();
045:                try {
046:                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
047:                } catch (Exception x) {
048:                    x.printStackTrace();
049:                }
050:            }
051:
052:            /**
053:             * Get a database connection.
054:             * @return a database connection
055:             */
056:            public java.sql.Connection getConnection()
057:                    throws java.sql.SQLException {
058:                return java.sql.DriverManager.getConnection("jdbc:odbc:test");
059:            }
060:
061:            /**
062:             * Get a database connection.
063:             * @return a database connection
064:             * @param userName a user name
065:             * @param password a password
066:             */
067:            public java.sql.Connection getConnection(String userName,
068:                    String password) throws java.sql.SQLException {
069:                return java.sql.DriverManager.getConnection("jdbc:odbc:test",
070:                        userName, password);
071:            }
072:
073:            /**
074:             * Get a connect string.
075:             * @return a string
076:             */
077:            public java.lang.String getConnectString() {
078:                return connectString;
079:            }
080:
081:            /**
082:             * Get tehn login toimeout.
083:             */
084:            public int getLoginTimeout() throws SQLException {
085:                return loginTimeout;
086:            }
087:
088:            /**
089:             * Get the log writer.
090:             */
091:            public PrintWriter getLogWriter() throws SQLException {
092:                return logWriter;
093:            }
094:
095:            /**
096:             * Get the password.
097:             * @return the database password
098:             */
099:            public String getPassword() {
100:                return password;
101:            }
102:
103:            /**
104:             * Get the user name for the database
105:             * @return the user name
106:             */
107:            public String getUserName() {
108:                return userName;
109:            }
110:
111:            /**
112:             * Set the connect string.
113:             * @param newConnectString java.lang.String
114:             */
115:            public void setConnectString(java.lang.String newConnectString) {
116:                connectString = newConnectString;
117:            }
118:
119:            /**
120:             * Set the login timeout.
121:             * @param millis the time in milli seconds
122:             */
123:            public void setLoginTimeout(int millis) throws SQLException {
124:                loginTimeout = millis;
125:            }
126:
127:            /**
128:             * Set the log writer.
129:             * @param writer a writer
130:             */
131:            public void setLogWriter(PrintWriter writer) throws SQLException {
132:                logWriter = writer;
133:            }
134:
135:            /**
136:             * Set a new password.
137:             * @param newPassword a password
138:             */
139:            public void setPassword(String newPassword) {
140:                password = newPassword;
141:            }
142:
143:            /**
144:             * Set a user name.
145:             * @param newUserName the user name
146:             */
147:            public void setUserName(String newUserName) {
148:                userName = newUserName;
149:            }
150:
151:            /**
152:             * Get a database driver class.
153:             * @return a database driver
154:             */
155:            public Class getDriver() {
156:                return driver;
157:            }
158:
159:            /**
160:             * Set a new driver class.
161:             * @param newDriver a jdbc driver class
162:             */
163:            public void setDriver(Class newDriver) {
164:                driver = newDriver;
165:            }
166:
167:            /**
168:             * Convert the object to a string.
169:             * @return a string representation of this object
170:             */
171:            public String toString() {
172:                return "data source dummy implementation for XKB testing only";
173:            }
174:
175:            /**
176:             * Compares objects.
177:             * @return a boolean
178:             * @param obj another object
179:             */
180:            public boolean equals(Object obj) {
181:                if (obj instanceof  DummyDataSource) {
182:                    DummyDataSource ds = (DummyDataSource) obj;
183:                    boolean result = true;
184:
185:                    result = result && (driver == ds.driver);
186:                    result = result && (loginTimeout == ds.loginTimeout);
187:                    result = result
188:                            && ((connectString == null) ? ds.connectString == null
189:                                    : connectString.equals(ds.connectString));
190:                    result = result
191:                            && ((userName == null) ? ds.userName == null
192:                                    : userName.equals(ds.userName));
193:                    result = result
194:                            && ((password == null) ? ds.password == null
195:                                    : password.equals(ds.password));
196:                    result = result
197:                            && ((logWriter == null) ? ds.logWriter == null
198:                                    : logWriter.equals(ds.logWriter));
199:
200:                    return result;
201:                }
202:
203:                return false;
204:            }
205:
206:            /**
207:             * Get the hash code of the object.
208:             * @return a hash code
209:             */
210:            public int hashCode() {
211:                return (connectString == null) ? 0 : connectString.hashCode();
212:            }
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.