Source Code Cross Referenced for TestView.java in  » Database-Client » ViennaSQL » uk » co » whisperingwind » vienna » 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 Client » ViennaSQL » uk.co.whisperingwind.vienna 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         ** $Id: TestView.java,v 1.4 2000/10/26 08:34:16 mrw Exp $
003:         **
004:         **
005:         ** Mike Wilson, October 2000, mrw@whisperingwind.co.uk
006:         **
007:         ** (C) Copyright 2000, Mike Wilson, Reading, Berkshire, UK
008:         **
009:         ** This program is free software; you can redistribute it and/or modify
010:         ** it under the terms of the GNU General Public License as published by
011:         ** the Free Software Foundation; either version 2 of the License, or
012:         ** (at your option) any later version.
013:         ** 
014:         ** This program is distributed in the hope that it will be useful,
015:         ** but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017:         ** GNU General Public License for more details.
018:         ** 
019:         ** You should have received a copy of the GNU Library General
020:         ** Public License along with this library; if not, write to the
021:         ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
022:         ** Boston, MA  02111-1307  USA.
023:         */
024:
025:        package uk.co.whisperingwind.vienna;
026:
027:        import java.awt.BorderLayout;
028:        import java.sql.Connection;
029:        import java.sql.DriverManager;
030:        import java.sql.SQLException;
031:        import javax.swing.JScrollPane;
032:        import javax.swing.JTextArea;
033:        import uk.co.whisperingwind.framework.ActionFactory;
034:        import uk.co.whisperingwind.framework.ModelEvent;
035:        import uk.co.whisperingwind.framework.PanelDialogView;
036:
037:        class TestView extends PanelDialogView implements  Runnable {
038:            private JTextArea resultText = new JTextArea(15, 40);
039:            private ActionFactory.DefaultAction dismissAction = null;
040:            private Thread testThread = null;
041:            private boolean continueTest = true;
042:
043:            private String url = null;
044:            private String driverClass = null;
045:            private String userName = null;
046:            private String password = null;
047:
048:            public TestView(String theUrl, String theDriverClass,
049:                    String theUserName, String thePassword) {
050:                super (null, false);
051:                content.setTitle("Connection test");
052:
053:                url = theUrl;
054:                driverClass = theDriverClass;
055:                userName = theUserName;
056:                password = thePassword;
057:
058:                JScrollPane scroller = new JScrollPane(resultText);
059:                resultText.setLineWrap(true);
060:                resultText.setWrapStyleWord(true);
061:                resultText.setEditable(false);
062:                panel.add(scroller, BorderLayout.CENTER);
063:
064:                ActionFactory factory = new ActionFactory(
065:                        "/uk/co/whisperingwind/images");
066:
067:                dismissAction = factory.createAction("dismiss");
068:                dismissAction.toolButtonFactory(buttonPanel);
069:                dismissAction.addActionListener(actionListener);
070:
071:                content.pack();
072:            }
073:
074:            public void startTest() {
075:                Thread t = new Thread(this );
076:                t.setDaemon(true);
077:                t.start();
078:            }
079:
080:            /*
081:             ** Synchronizing on resultText isn't really necessary -- only this
082:             ** thread updates it.
083:             **
084:             ** This shouldn't really be written like this -- a Swing component
085:             ** should never be updated by any thread other than event
086:             ** dispatch.
087:             */
088:
089:            public void run() {
090:                content.setVisible(true);
091:                boolean testPassed = true;
092:
093:                if (continueTest && testPassed) {
094:                    synchronized (resultText) {
095:                        resultText.append("Test 1: Load JDBC driver\n\n");
096:                    }
097:
098:                    try {
099:                        Class.forName(driverClass);
100:
101:                        synchronized (resultText) {
102:                            resultText.append("TEST 1 PASSED\n");
103:                        }
104:                    } catch (java.lang.ClassNotFoundException ex) {
105:                        testPassed = false;
106:
107:                        synchronized (resultText) {
108:                            resultText.append("TEST FAILED\n");
109:                            resultText.append("Cannot load the JDBC driver ");
110:                            resultText.append(driverClass);
111:                            resultText
112:                                    .append(". Please make sure the JDBC driver's");
113:                            resultText
114:                                    .append(" .zip or .jar file is correctly");
115:                            resultText.append(" installed in ");
116:                            resultText.append(System
117:                                    .getProperty("java.ext.dirs"));
118:                        }
119:                    }
120:                }
121:
122:                if (continueTest && testPassed) {
123:                    synchronized (resultText) {
124:                        resultText
125:                                .append("\nTest 2: Connect to the database\n\n");
126:                    }
127:
128:                    try {
129:                        DriverManager.getConnection(url, userName, password);
130:
131:                        synchronized (resultText) {
132:                            resultText.append("TEST 2 PASSED\n");
133:                        }
134:                    } catch (SQLException ex) {
135:                        testPassed = false;
136:
137:                        synchronized (resultText) {
138:                            resultText.append("TEST FAILED\n");
139:                            resultText
140:                                    .append("Cannot connect to the database using ");
141:                            resultText
142:                                    .append("the specified user name and password.");
143:                            resultText
144:                                    .append(" Please check the URL, user name and ");
145:                            resultText.append("password are correct.\n\n");
146:                            resultText
147:                                    .append("Messaged returned by the driver");
148:                            resultText.append(" is " + ex.getMessage());
149:                        }
150:                    }
151:                }
152:
153:                if (continueTest && testPassed) {
154:                    synchronized (resultText) {
155:                        resultText.append("\nALL TESTS PASSED\n");
156:                    }
157:                }
158:            }
159:
160:            protected void modelEvent(ModelEvent event) {
161:            }
162:
163:            protected void cleanUp() {
164:            }
165:
166:            public void closeDialog() {
167:                stopThread();
168:                super .closeDialog();
169:            }
170:
171:            private synchronized void stopThread() {
172:                if (testThread != null) {
173:                    stopTest();
174:                    testThread.interrupt();
175:
176:                    try {
177:                        testThread.join();
178:                        testThread = null;
179:                    } catch (InterruptedException ex) {
180:                        // Do nothing
181:                    }
182:                }
183:            }
184:
185:            private synchronized void stopTest() {
186:                continueTest = false;
187:            }
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.