1 /* |
1 /* |
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
52 |
52 |
53 // Fields |
53 // Fields |
54 |
54 |
55 /** |
55 /** |
56 */ |
56 */ |
57 private String sqlState = null; |
57 private final String sqlState; |
58 |
58 |
59 /** |
59 /** |
60 */ |
60 */ |
61 private int vendorCode = -1; |
61 private final int vendorCode; |
62 |
62 |
63 /** |
63 /** |
64 * The SQL string that was sent to the database. |
64 * The SQL string that was sent to the database. |
65 */ |
65 */ |
66 private String sqlString = null; |
66 private final String sqlString; |
67 |
67 |
68 /** |
68 /** |
69 * The index of the first character in SQL where an error is detected. Zero |
69 * The index of the first character in SQL where an error is detected. Zero |
70 * based. |
70 * based. |
71 */ |
71 */ |
72 private int position = -1; |
72 private final int position; |
73 |
73 |
74 // Constructors |
74 // Constructors |
75 |
75 |
76 private SqlException() { |
|
77 super(); |
|
78 } |
|
79 |
|
80 /** |
76 /** |
81 * |
77 * |
82 * @param message a description of the exception |
78 * @param message |
83 * @param cause the underlying reason for this SqlException |
79 * @param cause |
84 * (which is saved for later retrieval by the getCause() method); |
80 * @param sqlState |
85 * may be null indicating the cause is non-existent or unknown. |
81 * @param vendorCode |
86 * @param sqlState an XOPEN or SQL:2003 code identifying the exception |
82 * @param sql |
87 * @param vendorCode a database vendor-specific exception code |
83 * @param position |
88 * @param sql the SQL string that was sent to the database |
|
89 * @param position the index of the first character in SQL where an error is detected. Zero |
|
90 * based |
|
91 */ |
84 */ |
92 public SqlException(String message, Throwable cause, String sqlState, int vendorCode, String sql, int position) { |
85 public SqlException(String message, Throwable cause, String sqlState, int vendorCode, String sql, int position) { |
93 super(message, cause); |
86 super(message, cause); |
94 this.sqlState = sqlState; |
87 this.sqlState = sqlState; |
95 this.vendorCode = vendorCode; |
88 this.vendorCode = vendorCode; |