Skip to content

Commit

Permalink
Handle errors more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Aug 14, 2013
1 parent 4a2549b commit 3077783
Showing 1 changed file with 10 additions and 5 deletions.
Expand Up @@ -28,7 +28,6 @@
import javax.sql.DataSource;

import org.jumpmind.db.platform.DatabaseInfo;
import org.jumpmind.db.platform.sqlanywhere.SqlAnywhereJdbcSqlTemplate;
import org.jumpmind.db.sql.ISqlTemplate;
import org.jumpmind.db.sql.ISqlTransaction;
import org.jumpmind.db.sql.JdbcSqlTemplate;
Expand Down Expand Up @@ -74,15 +73,21 @@ protected void setDecimalValue(PreparedStatement ps, int i, Object arg, int argT
Method method = null;
try {
method = clazz.getMethod("setBigDecimal", parameterTypes);
BigDecimal value = (BigDecimal) arg;
BigDecimal value = null;
if (arg instanceof BigDecimal) {
value = (BigDecimal)arg;
} else if (arg != null) {
value = new BigDecimal(arg.toString());
}
Object[] params = new Object[] { new Integer(i), value,
new Integer(value.precision()), new Integer(value.scale()) };
method.invoke(nativeStatement, params);
} catch (Exception e) {
log.info("Can't find stmt.setBigDecimal(int,BigDecimal,int,int) method: "
+ e.getMessage());
return;
log.warn("Had trouble calling the Sybase stmt.setBigDecimal(int,BigDecimal,int,int) method", e);
super.setDecimalValue(ps, i, arg, argType);
}
} else {
super.setDecimalValue(ps, i, arg, argType);
}
}

Expand Down

0 comments on commit 3077783

Please sign in to comment.