|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2012 the original author or authors. |
| 2 | + * Copyright 2002-2015 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -51,37 +51,51 @@ public class Jdbc4SqlXmlHandler implements SqlXmlHandler {
|
51 | 51 | //-------------------------------------------------------------------------
|
52 | 52 |
|
53 | 53 | public String getXmlAsString(ResultSet rs, String columnName) throws SQLException {
|
54 |
| - return rs.getSQLXML(columnName).getString(); |
| 54 | + SQLXML xmlObject = rs.getSQLXML(columnName); |
| 55 | + return (xmlObject != null ? xmlObject.getString() : null); |
55 | 56 | }
|
56 | 57 |
|
57 | 58 | public String getXmlAsString(ResultSet rs, int columnIndex) throws SQLException {
|
58 |
| - return rs.getSQLXML(columnIndex).getString(); |
| 59 | + SQLXML xmlObject = rs.getSQLXML(columnIndex); |
| 60 | + return (xmlObject != null ? xmlObject.getString() : null); |
59 | 61 | }
|
60 | 62 |
|
61 | 63 | public InputStream getXmlAsBinaryStream(ResultSet rs, String columnName) throws SQLException {
|
62 |
| - return rs.getSQLXML(columnName).getBinaryStream(); |
| 64 | + SQLXML xmlObject = rs.getSQLXML(columnName); |
| 65 | + return (xmlObject != null ? xmlObject.getBinaryStream() : null); |
63 | 66 | }
|
64 | 67 |
|
65 | 68 | public InputStream getXmlAsBinaryStream(ResultSet rs, int columnIndex) throws SQLException {
|
66 |
| - return rs.getSQLXML(columnIndex).getBinaryStream(); |
| 69 | + SQLXML xmlObject = rs.getSQLXML(columnIndex); |
| 70 | + return (xmlObject != null ? xmlObject.getBinaryStream() : null); |
67 | 71 | }
|
68 | 72 |
|
69 | 73 | public Reader getXmlAsCharacterStream(ResultSet rs, String columnName) throws SQLException {
|
70 |
| - return rs.getSQLXML(columnName).getCharacterStream(); |
| 74 | + SQLXML xmlObject = rs.getSQLXML(columnName); |
| 75 | + return (xmlObject != null ? xmlObject.getCharacterStream() : null); |
71 | 76 | }
|
72 | 77 |
|
73 | 78 | public Reader getXmlAsCharacterStream(ResultSet rs, int columnIndex) throws SQLException {
|
74 |
| - return rs.getSQLXML(columnIndex).getCharacterStream(); |
| 79 | + SQLXML xmlObject = rs.getSQLXML(columnIndex); |
| 80 | + return (xmlObject != null ? xmlObject.getCharacterStream() : null); |
75 | 81 | }
|
76 | 82 |
|
77 | 83 | @SuppressWarnings("unchecked")
|
78 | 84 | public Source getXmlAsSource(ResultSet rs, String columnName, Class sourceClass) throws SQLException {
|
79 |
| - return rs.getSQLXML(columnName).getSource(sourceClass != null ? sourceClass : DOMSource.class); |
| 85 | + SQLXML xmlObject = rs.getSQLXML(columnName); |
| 86 | + if (xmlObject == null) { |
| 87 | + return null; |
| 88 | + } |
| 89 | + return xmlObject.getSource(sourceClass != null ? sourceClass : DOMSource.class); |
80 | 90 | }
|
81 | 91 |
|
82 | 92 | @SuppressWarnings("unchecked")
|
83 | 93 | public Source getXmlAsSource(ResultSet rs, int columnIndex, Class sourceClass) throws SQLException {
|
84 |
| - return rs.getSQLXML(columnIndex).getSource(sourceClass != null ? sourceClass : DOMSource.class); |
| 94 | + SQLXML xmlObject = rs.getSQLXML(columnIndex); |
| 95 | + if (xmlObject == null) { |
| 96 | + return null; |
| 97 | + } |
| 98 | + return xmlObject.getSource(sourceClass != null ? sourceClass : DOMSource.class); |
85 | 99 | }
|
86 | 100 |
|
87 | 101 |
|
|
0 commit comments