Nuts Insert a database in the following ways:
Dao.insert ();
Dao.excute (SQL);
and other ways. However, you cannot return the inserted ID.
The following methods can be implemented:
/**t_plan_keyword table id*/
private static Long Keywordid =-1;
/**
* Insert database according to keyword and return ID
* @param dao
* @param keyword keyword
* @return
/public static Long Insertkeyword (Dao dao,final String keyword) {
dao.run (new Conncallback () {
@Override public
Void Invoke (Connection conn) throws Exception {
String SqlString = "INSERT into T_plan_keyword (keyword) VALUES ('" +keywor D+ "')";
Statement stmt = Conn.createstatement ();
Stmt.executeupdate (SqlString, Statement.return_generated_keys);
ResultSet rs = Stmt.getgeneratedkeys ();
if (Rs.next ()) Keywordid = Rs.getlong (1) ;
if (Rs!= null) rs.close ();
if (stmt!= null) stmt.close ();
}
});
return keywordid;
}