Correctly handle nulls for JDBC Connector dependencies.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 21 Aug 2003 21:04:11 +0000 (21:04 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 21 Aug 2003 21:04:11 +0000 (21:04 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@738 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/attrresolv/provider/JDBCDataConnector.java

index da313f2..f304db8 100644 (file)
@@ -730,7 +730,16 @@ class DependencyStatementCreator implements JDBCStatementCreator {
                private void setSpecificParameter(PreparedStatement preparedStatement, int valueIndex, Object object)
                        throws JDBCStatementCreatorException {
 
-                       if (type.equalsIgnoreCase("String")) {
+                       if (object == null) {
+                               try {
+                                       preparedStatement.setNull(valueIndex, Types.NULL);
+                                       return;
+                               } catch (SQLException e) {
+                                       log.error(
+                                               "Encountered a problem while attempting to convert missing attribute value to null parameter.");
+                                       throw new JDBCStatementCreatorException("Encountered a problem while attempting to convert missing attribute value to null parameter.");
+                               }
+                       } else if (type.equalsIgnoreCase("String")) {
                                setString(preparedStatement, valueIndex, object);
                        } else if (type.equalsIgnoreCase("Integer")) {
                                setInteger(preparedStatement, valueIndex, object);