I am working in Java, inserting data from HashMaps of certain types into a SQL database. It has produced some code like this:
for ( String key : strings.keySet() ) {
result_set.updateString(key, strings.get(key));
}
for ( String key : booleans.keySet() ) {
result_set.updateBoolean(key, booleans.get(key));
}
for ( String key : dates.keySet() ) {
result_set.updateDate(key, dates.get(key));
}
I am used to Ruby, where code like this would take up one line and I can't believe I have to do it like this in Java. I must be wrong. Is there a better way? I assume using Generics? I tried using result_set.updateObject(key, object) but it gave me "SQLException: Unable to convert between java.util.Date and VARCHAR."