Prepare SQL query example

//===========================================================
// Prepare a SQL query to insert a row into the breed table.
//===========================================================
query = “INSERT INTO breed ”
+ “(thekey,”
+ “species_key,”
+ “breed_name,”
+ “breed_ext_id,”
+ “create_user,”
+ “create_stamp,”
+ “update_user,”
+ “update_stamp) ”
+ “VALUES(?,?,?,?,”
+ “?,CURRENT_TIMESTAMP,?,CURRENT_TIMESTAMP)”;
ps = conn.prepareStatement(query);
ps.setInt(1, brdKey);
ps.setInt(2, formDO.getSpeciesKey());
ps.setString(3, formDO.getBreedName());
ps.setString(4, formDO.getBreedExtId().toUpperCase());
ps.setString(5, request.getSession().getAttribute(“USERNAME”).toString());
ps.setString(6, request.getSession().getAttribute(“USERNAME”).toString());
ps.executeUpdate();

About admin

Richard Wolschlager is the owner of Wolmerica Technologies LLC and holds a (93) Bachelors of Science degree in Computer Science with a minor in Mathematics from Saginaw Valley State University. Richard has worked in the Information Technology field for 20 years on a variety of platforms and lines of business.
This entry was posted in Java. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *