java - Can I pass column names in this manner? -
query = "update personal_details set '" + field + "' = '" + edit + "' associate_id = '" + associate_id + "'";
here table name personal_details
, taking table column name parameter in variable filed , new value in edit. code in java. , database i'm accessing in postgresql.
although can build string using plain concatenation, more recommended ways are:
- use stringbuilder/stringbuffer when build strings optimize program speed, specially if concatenate strings inside loop;
- the recommended way use preparedstatement , fill parameter values. see: http://docs.oracle.com/javase/tutorial/jdbc/basics/prepared.html
Comments
Post a Comment