String uuid = Uuid.randomuuid (). toString (). Trim (). ReplaceAll ("-", ""), manual automatic generation of UUID this table primary key (the primary role is that the database generates unique, It can be used to generate a primary key such as this table, and the authorization code like here is unique to everyone, so use this to generate. )
String uuid, the generated assignment to Uudi, and then the UUID in the SQL statement written to the database, write the premise, the database must have this UUID column properties.
When writing to the database here, do not need to the same as other properties in the page to write the Set,get method, where you do not have to write directly inside the SQL, and then in the Jdbctemplate.update statement should be corresponding to write on it.
@Service
@Transactional
public class UserService {
@Autowired
Private JdbcTemplate JdbcTemplate;
Public Json Register (agentregistered_page Page) {
JSON JSON = new JSON ();
Manually automatically generate UUID this table primary key
String uuid = Uuid.randomuuid (). toString (). Trim (). ReplaceAll ("-", "" ");
Manual automatic generation of accredit authorization codes
String Accredit=uuid.randomuuid (). toString (). Trim (). ReplaceAll ("-", "" ");
String sql= "INSERT INTO agency (Uuid,accredit,account,password,phonenumber,realname,idcardnumber,agentregion, Nameofcompany,referees,agencyhead,photoagencyasalegalperson,thebusinesslicense,duplicateofbusinesslicense, thebankopensanaccountlicence,pid,encrypted_problem_one,encrypted_problem_two,encrypted_problem_three,encrypted _answers_one,encrypted_answers_two,encrypted_answers_three,province,city,area) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,? ,?,?,?,?,?,?,?,?,?,?,?,?) ";
Jdbctemplate.update (Sql,uuid,accredit,page.getaccount (), Page.getpassword (), Page.getphonenumber (), Page.getrealname (), Page.getidcardnumber (), Page.getagentregion (), Page.getnameofcompany (), Page.getReferees (), Page.getagencyhead (), Page.getphotoagencyasalegalperson (), Page.getthebusinesslicense (), Page.getduplicateofbusinesslicense (), Page.getthebankopensanaccountlicence (), Page.getpid (), Page.getEncrypted_ Problem_one (), Page.getencrypted_problem_two (), Page.getencrypted_problem_three (), Page.getencrypted_answers_one ( ), Page.getencrypted_answers_two (), Page.getencrypted_answers_three (), Page.getprovince (), page.getCity (), Page.getarea ());
return JSON;
}
}
SPRINGMVC+JDBC Connection Database (first micro-commerce project, Agent registration)