Hi at now i am programming with Java and wanting to insert some value to specific column choosen. Also, i want to add it in parameter similar with C#:
example:
SqlCommand cmdb = new SqlCommand("insert into Assignment1(textname,person,date,text)
values (@textName,@person,@date,@text)", con);
cmdb.Parameters.AddWithValue("@textname", textPathLabel.Text);
cmdb.Parameters.AddWithValue("@person", personNameTB.Text);
cmdb.Parameters.AddWithValue("@date", DateTime.Now);
cmdb.Parameters.AddWithValue("@text", theBytes);
What you need is to use PreparedStatement in Java. With the example that you’ve, the corresponding PreparedStatement would look something like this:
You would then use the appropriate
ps.setXX()methods to set the appropriate values for the parameters that you’ve defined and then callps.executeUpdate()to execute the call to the database.The “JDBC(TM) Database Access” would be a good place to start learning about how to use or execute common SQL statements, and perform other objectives common to database applications.