Dynamically Insert Variables into DB Table using PreparedStatement
Posted
by
gran_profaci
on Stack Overflow
See other posts from Stack Overflow
or by gran_profaci
Published on 2013-07-03T05:02:44Z
Indexed on
2013/07/03
5:05 UTC
Read the original article
Hit count: 182
I was working with PreparedStatement today and noticed that it used setString() setTimestamp() etc. to insert variables into the DB.
I basically have 20 tables each with at least 15 columns and it would not be feasible for me to manuallt write down all the setters. Considering that I have an ArrayList "Vals" which contains all the variables to be inputted in String format (obtained by getString() using PreparedStatement itself), is there any way I can do an insert without using expressly using the Setters? That would save me a lot of time.
© Stack Overflow or respective owner