Better automatic type conversion for Dependency Statement Creator.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 22 Aug 2003 18:17:19 +0000 (18:17 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 22 Aug 2003 18:17:19 +0000 (18:17 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@741 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

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

index f304db8..0094088 100644 (file)
@@ -897,9 +897,9 @@ class DependencyStatementCreator implements JDBCStatementCreator {
 
                private void setLong(PreparedStatement preparedStatement, int valueIndex, Object object)
                        throws JDBCStatementCreatorException {
-                       if (object instanceof Long) {
+                       if (object instanceof Long || object instanceof Integer || object instanceof Short) {
                                try {
-                                       preparedStatement.setLong(valueIndex, ((Long) object).longValue());
+                                       preparedStatement.setLong(valueIndex, ((Number) object).longValue());
                                        return;
                                } catch (SQLException e) {
                                        log.error("Encountered an error while adding parameter to prepared statement: " + e);
@@ -947,9 +947,9 @@ class DependencyStatementCreator implements JDBCStatementCreator {
 
                private void setDouble(PreparedStatement preparedStatement, int valueIndex, Object object)
                        throws JDBCStatementCreatorException {
-                       if (object instanceof Double) {
+                       if (object instanceof Double || object instanceof Float) {
                                try {
-                                       preparedStatement.setDouble(valueIndex, ((Double) object).doubleValue());
+                                       preparedStatement.setDouble(valueIndex, ((Number) object).doubleValue());
                                        return;
                                } catch (SQLException e) {
                                        log.error("Encountered an error while adding parameter to prepared statement: " + e);
@@ -997,9 +997,9 @@ class DependencyStatementCreator implements JDBCStatementCreator {
 
                private void setInteger(PreparedStatement preparedStatement, int valueIndex, Object object)
                        throws JDBCStatementCreatorException {
-                       if (object instanceof Integer) {
+                       if (object instanceof Integer || object instanceof Short) {
                                try {
-                                       preparedStatement.setInt(valueIndex, ((Integer) object).intValue());
+                                       preparedStatement.setInt(valueIndex, ((Number) object).intValue());
                                        return;
                                } catch (SQLException e) {
                                        log.error("Encountered an error while adding parameter to prepared statement: " + e);