|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2013 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.
|
@@ -53,43 +53,55 @@ public class Jdbc4SqlXmlHandler implements SqlXmlHandler {
|
53 | 53 |
|
54 | 54 | @Override
|
55 | 55 | public String getXmlAsString(ResultSet rs, String columnName) throws SQLException {
|
56 |
| - return rs.getSQLXML(columnName).getString(); |
| 56 | + SQLXML xmlObject = rs.getSQLXML(columnName); |
| 57 | + return (xmlObject != null ? xmlObject.getString() : null); |
57 | 58 | }
|
58 | 59 |
|
59 | 60 | @Override
|
60 | 61 | public String getXmlAsString(ResultSet rs, int columnIndex) throws SQLException {
|
61 |
| - return rs.getSQLXML(columnIndex).getString(); |
| 62 | + SQLXML xmlObject = rs.getSQLXML(columnIndex); |
| 63 | + return (xmlObject != null ? xmlObject.getString() : null); |
62 | 64 | }
|
63 | 65 |
|
64 | 66 | @Override
|
65 | 67 | public InputStream getXmlAsBinaryStream(ResultSet rs, String columnName) throws SQLException {
|
66 |
| - return rs.getSQLXML(columnName).getBinaryStream(); |
| 68 | + SQLXML xmlObject = rs.getSQLXML(columnName); |
| 69 | + return (xmlObject != null ? xmlObject.getBinaryStream() : null); |
67 | 70 | }
|
68 | 71 |
|
69 | 72 | @Override
|
70 | 73 | public InputStream getXmlAsBinaryStream(ResultSet rs, int columnIndex) throws SQLException {
|
71 |
| - return rs.getSQLXML(columnIndex).getBinaryStream(); |
| 74 | + SQLXML xmlObject = rs.getSQLXML(columnIndex); |
| 75 | + return (xmlObject != null ? xmlObject.getBinaryStream() : null); |
72 | 76 | }
|
73 | 77 |
|
74 | 78 | @Override
|
75 | 79 | public Reader getXmlAsCharacterStream(ResultSet rs, String columnName) throws SQLException {
|
76 |
| - return rs.getSQLXML(columnName).getCharacterStream(); |
| 80 | + SQLXML xmlObject = rs.getSQLXML(columnName); |
| 81 | + return (xmlObject != null ? xmlObject.getCharacterStream() : null); |
77 | 82 | }
|
78 | 83 |
|
79 | 84 | @Override
|
80 | 85 | public Reader getXmlAsCharacterStream(ResultSet rs, int columnIndex) throws SQLException {
|
81 |
| - return rs.getSQLXML(columnIndex).getCharacterStream(); |
| 86 | + SQLXML xmlObject = rs.getSQLXML(columnIndex); |
| 87 | + return (xmlObject != null ? xmlObject.getCharacterStream() : null); |
82 | 88 | }
|
83 | 89 |
|
84 | 90 | @Override
|
85 | 91 | public Source getXmlAsSource(ResultSet rs, String columnName, Class<? extends Source> sourceClass) throws SQLException {
|
86 | 92 | SQLXML xmlObject = rs.getSQLXML(columnName);
|
| 93 | + if (xmlObject == null) { |
| 94 | + return null; |
| 95 | + } |
87 | 96 | return (sourceClass != null ? xmlObject.getSource(sourceClass) : xmlObject.getSource(DOMSource.class));
|
88 | 97 | }
|
89 | 98 |
|
90 | 99 | @Override
|
91 | 100 | public Source getXmlAsSource(ResultSet rs, int columnIndex, Class<? extends Source> sourceClass) throws SQLException {
|
92 | 101 | SQLXML xmlObject = rs.getSQLXML(columnIndex);
|
| 102 | + if (xmlObject == null) { |
| 103 | + return null; |
| 104 | + } |
93 | 105 | return (sourceClass != null ? xmlObject.getSource(sourceClass) : xmlObject.getSource(DOMSource.class));
|
94 | 106 | }
|
95 | 107 |
|
|
0 commit comments