How to set parameters dynamically to prepared statement using jdbc? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to set parameters dynamically to prepared statement using jdbc?

Means i want to have a method which can do that for me.

24th Aug 2019, 10:40 AM
Anubhav Gupta
Anubhav Gupta - avatar
2 Answers
+ 2
Since a prepared statement takes a string param, you can just create a method which does the task for you by changing the values of the “sql” command when executing. For example if you are creating a table you can create a method which takes the param of the Connection, tableName, type of main key etc etc
24th Aug 2019, 3:51 PM
Andy Wong
Andy Wong - avatar
0
Hi Andy Thanks for the response. Can you give small example using that with jdbc
24th Aug 2019, 5:55 PM
Anubhav Gupta
Anubhav Gupta - avatar