Source Code Cross Referenced for EmbedSQLException.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » jdbc » 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 DBMS » db derby 10.2 » org.apache.derby.impl.jdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.jdbc.EmbedSQLException
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.jdbc;
023:
024:        import org.apache.derby.iapi.error.StandardException;
025:
026:        import java.sql.SQLException;
027:        import java.io.PrintStream;
028:        import java.io.PrintWriter;
029:
030:        /**
031:         This class is what gets send over the wire in client/server
032:         configuration. When running embedded, this has the detailed
033:         stack trace for exceptions. In case of client/server, server
034:         has all the stack trace information but client doesn't get
035:         the stack trace, just the sql exception. The reason for this
036:         implementation is the stack trace information is more relevant
037:         on the server side and it also decreases the size of client
038:         jar file tremendously.
039:         */
040:        public class EmbedSQLException extends SQLException {
041:
042:            private transient Object[] arguments;
043:            private String messageId;
044:
045:            /**
046:            	Java exception that caused this exception, can be null.
047:             */
048:            //Because it's transient, it doesn't get sent over to the client
049:            //side and hence the classes which needs to be included in the
050:            //client.jar file decreases 5 folds.
051:            private transient Throwable javaException;
052:
053:            /**
054:             * Because SQLException does not have settable fields,
055:             * the caller of the constructor must do message lookup,
056:             * and pass the appropriate values here for message, messageId,
057:             * and next exception.
058:             */
059:            EmbedSQLException(String message, String messageId,
060:                    SQLException nextException, int severity, Object[] args) {
061:
062:                super (message, StandardException
063:                        .getSQLStateFromIdentifier(messageId), severity);
064:                this .messageId = messageId;
065:                arguments = args;
066:                if (nextException != null)
067:                    this .setNextException(nextException);
068:            }
069:
070:            public EmbedSQLException(String message, String messageId,
071:                    SQLException nextException, int severity, Throwable t,
072:                    Object[] args) {
073:
074:                super (message, StandardException
075:                        .getSQLStateFromIdentifier(messageId), severity);
076:                this .messageId = messageId;
077:                arguments = args;
078:                if (nextException != null)
079:                    this .setNextException(nextException);
080:                javaException = t;
081:            }
082:
083:            public Throwable getJavaException() {
084:                return javaException;
085:            }
086:
087:            public String getMessageId() {
088:                return messageId;
089:            }
090:
091:            public Object[] getArguments() {
092:                return arguments;
093:            }
094:
095:            /**
096:            	Print the stack trace of the wrapped java exception or this
097:            	exception if there is none.
098:
099:            	@see Throwable#printStackTrace
100:             */
101:            public void printStackTrace() {
102:                Throwable je = getJavaException();
103:                if (je != null)
104:                    je.printStackTrace();
105:                else
106:                    super .printStackTrace();
107:            }
108:
109:            /**
110:            	Print the stack trace of the wrapped java exception or this
111:            	exception if there is none.
112:
113:            	@see Throwable#printStackTrace
114:             */
115:            public void printStackTrace(PrintStream s) {
116:                Throwable je = getJavaException();
117:                if (je != null)
118:                    je.printStackTrace(s);
119:                else
120:                    super .printStackTrace(s);
121:            }
122:
123:            /**
124:            	Print the stack trace of the wrapped java exception or this
125:            	exception if there is none.
126:
127:            	@see Throwable#printStackTrace
128:             */
129:            public void printStackTrace(PrintWriter s) {
130:                Throwable je = getJavaException();
131:                if (je != null)
132:                    je.printStackTrace(s);
133:                else
134:                    super .printStackTrace(s);
135:            }
136:
137:            /*
138:             ** Methods of Object
139:             */
140:
141:            /**
142:            	Override Throwables toString() to avoid the class name
143:            	appearing in the message.
144:             */
145:            public String toString() {
146:                // We use java.sql.SQLException rather than the default toString(),
147:                // which returns org.apache.derby.impl.jdbc.EmbedSQLException, so
148:                // that (a) we're not exposing an internal class name and (b) so
149:                // this is consistent with the network client, where SQLExceptions
150:                // are vanilla java.sql classes and not our own subclass
151:                return "java.sql.SQLException: " + getMessage();
152:            }
153:
154:            /*
155:             ** Some hack methods for 3.0.1. These will get cleaned up in main
156:             ** with the exception re-work.
157:             */
158:            private transient boolean simpleWrapper;
159:
160:            public static SQLException wrapStandardException(String message,
161:                    String messageId, int code, Throwable se) {
162:                EmbedSQLException csqle = new EmbedSQLException(
163:                        message,
164:                        messageId,
165:                        (SQLException) null,
166:                        code,
167:                        se,
168:                        (se instanceof  StandardException) ? ((StandardException) se)
169:                                .getArguments()
170:                                : null);
171:                csqle.simpleWrapper = true;
172:                return csqle;
173:            }
174:
175:            public boolean isSimpleWrapper() {
176:                return simpleWrapper;
177:            }
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.