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(?,?,?,?,”
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());

About admin

Richard has worked in the Information Technology field for 25 years on a variety of platforms and lines of business.
This entry was posted in Java. Bookmark the permalink.