I'm still having trouble with the fact that you can't use a PreparedStatement because your insert is "dynamic"... Can you give a concrete example? Perhaps there is a way to use PreparedStatement after all...
I do have a master table in which some fields are optional including the picture , a user can enter certain details or prefer not to. So my query will be dynamically generated one according to the user inputs. from what i understood PreparedStatements are pre-compiled . what i am currently doing is inserting the all other details using a dynamically generated query and taking the auoto generated id from the database then update the particular column .I want to avoid this repeated access to database for accessing the same table .
here is the code im working with .please correct me if i am doing it wrongly
That could still be a prepared statement. The driver would cache it as two statements - one with the e-mail and one without. But the database would cache the execution plan. There is still a benefit to using a prepared statement with the code you posted.