Source Code Cross Referenced for DataTruncation.java in  » 6.0-JDK-Core » sql » java » sql » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » sql » java.sql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1996-2005 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package java.sql;
027
028        /**
029         * An exception  thrown as a <code>DataTruncation</code> exception
030         * (on writes) or reported as a 
031         * <code>DataTruncation</code> warning (on reads)
032         *  when a data values is unexpectedly truncated for reasons other than its having
033         *  execeeded <code>MaxFieldSize</code>.
034         *
035         * <P>The SQLstate for a <code>DataTruncation</code> during read is <code>01004</code>.
036         * <P>The SQLstate for a <code>DataTruncation</code> during write is <code>22001</code>.
037         */
038
039        public class DataTruncation extends SQLWarning {
040
041            /**
042             * Creates a <code>DataTruncation</code> object
043             * with the SQLState initialized
044             * to 01004 when <code>read</code> is set to <code>true</code> and 22001
045             * when <code>read</code> is set to <code>false</code>, 
046             * the reason set to "Data truncation", the
047             * vendor code set to 0, and
048             * the other fields set to the given values.
049             * The <code>cause</code> is not initialized, and may subsequently be 
050             * initialized by a call to the 
051             * {@link Throwable#initCause(java.lang.Throwable)} method.
052             * <p>
053             *
054             * @param index The index of the parameter or column value
055             * @param parameter true if a parameter value was truncated
056             * @param read true if a read was truncated
057             * @param dataSize the original size of the data
058             * @param transferSize the size after truncation
059             */
060            public DataTruncation(int index, boolean parameter, boolean read,
061                    int dataSize, int transferSize) {
062                super ("Data truncation", read == true ? "01004" : "22001");
063                this .index = index;
064                this .parameter = parameter;
065                this .read = read;
066                this .dataSize = dataSize;
067                this .transferSize = transferSize;
068
069            }
070
071            /**
072             * Creates a <code>DataTruncation</code> object
073             * with the SQLState initialized
074             * to 01004 when <code>read</code> is set to <code>true</code> and 22001
075             * when <code>read</code> is set to <code>false</code>, 
076             * the reason set to "Data truncation", the
077             * vendor code set to 0, and
078             * the other fields set to the given values.
079             * <p>
080             *
081             * @param index The index of the parameter or column value
082             * @param parameter true if a parameter value was truncated
083             * @param read true if a read was truncated
084             * @param dataSize the original size of the data
085             * @param transferSize the size after truncation
086             * @param cause the underlying reason for this <code>DataTruncation</code> 
087             * (which is saved for later retrieval by the <code>getCause()</code> method);
088             * may be null indicating the cause is non-existent or unknown.
089             *
090             * @since 1.6
091             */
092            public DataTruncation(int index, boolean parameter, boolean read,
093                    int dataSize, int transferSize, Throwable cause) {
094                super ("Data truncation", read == true ? "01004" : "22001",
095                        cause);
096                this .index = index;
097                this .parameter = parameter;
098                this .read = read;
099                this .dataSize = dataSize;
100                this .transferSize = transferSize;
101            }
102
103            /**
104             * Retrieves the index of the column or parameter that was truncated.
105             *
106             * <P>This may be -1 if the column or parameter index is unknown, in 
107             * which case the <code>parameter</code> and <code>read</code> fields should be ignored.
108             *
109             * @return the index of the truncated paramter or column value
110             */
111            public int getIndex() {
112                return index;
113            }
114
115            /**
116             * Indicates whether the value truncated was a parameter value or
117             * a column value.
118             *
119             * @return <code>true</code> if the value truncated was a parameter;
120             *         <code>false</code> if it was a column value
121             */
122            public boolean getParameter() {
123                return parameter;
124            }
125
126            /**
127             * Indicates whether or not the value was truncated on a read.
128             *
129             * @return <code>true</code> if the value was truncated when read from
130             *         the database; <code>false</code> if the data was truncated on a write
131             */
132            public boolean getRead() {
133                return read;
134            }
135
136            /**
137             * Gets the number of bytes of data that should have been transferred.
138             * This number may be approximate if data conversions were being
139             * performed.  The value may be <code>-1</code> if the size is unknown.
140             *
141             * @return the number of bytes of data that should have been transferred
142             */
143            public int getDataSize() {
144                return dataSize;
145            }
146
147            /**
148             * Gets the number of bytes of data actually transferred.
149             * The value may be <code>-1</code> if the size is unknown.
150             *
151             * @return the number of bytes of data actually transferred
152             */
153            public int getTransferSize() {
154                return transferSize;
155            }
156
157            /**
158             * @serial
159             */
160            private int index;
161
162            /**
163             * @serial
164             */
165            private boolean parameter;
166
167            /**
168             * @serial
169             */
170            private boolean read;
171
172            /**
173             * @serial
174             */
175            private int dataSize;
176
177            /**
178             * @serial
179             */
180            private int transferSize;
181
182            /**
183             * @serial
184             */
185            private static final long serialVersionUID = 6464298989504059473L;
186
187        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.