我在项目中使用Spring JdbcTemplates,我想将数据插入Oracle数据库。插入数据后,我需要此插入值的ID([[False False False True False]
[ True True False True True]
[ True True True True True]
[ True True True False True]
[ True True True True False]]
FOR POSITION 0 0 FOUND 2 MINES.
FOR POSITION 0 1 FOUND 2 MINES.
FOR POSITION 0 2 FOUND 3 MINES.
FOR POSITION 0 3 FOUND 3 MINES.
FOR POSITION 0 4 FOUND 3 MINES.
FOR POSITION 1 0 FOUND 4 MINES.
FOR POSITION 1 1 FOUND 5 MINES.
FOR POSITION 1 2 FOUND 6 MINES.
FOR POSITION 1 3 FOUND 6 MINES.
FOR POSITION 1 4 FOUND 5 MINES.
FOR POSITION 2 0 FOUND 6 MINES.
FOR POSITION 2 1 FOUND 8 MINES.
FOR POSITION 2 2 FOUND 7 MINES.
FOR POSITION 2 3 FOUND 7 MINES.
FOR POSITION 2 4 FOUND 5 MINES.
FOR POSITION 3 0 FOUND 6 MINES.
FOR POSITION 3 1 FOUND 9 MINES.
FOR POSITION 3 2 FOUND 8 MINES.
FOR POSITION 3 3 FOUND 7 MINES.
FOR POSITION 3 4 FOUND 4 MINES.
FOR POSITION 4 0 FOUND 4 MINES.
FOR POSITION 4 1 FOUND 6 MINES.
FOR POSITION 4 2 FOUND 5 MINES.
FOR POSITION 4 3 FOUND 4 MINES.
FOR POSITION 4 4 FOUND 2 MINES.
),以便我可以使用它。
v.z = this.gameObject.transform.position.z;
v.y = this.gameObject.transform.position.y;
v.x = this.gameObject.transform.position.x;
if( Input.GetKey( KeyCode.UpArrow ) )
v.z += 0.5f;
else if( Input.GetKey( KeyCode.DownArrow ) )
v.z -= 0.5f;
现在,表格中的字段void Update() {
if( Input.GetKey( KeyCode.RightArrow ) )
transform.Rotate(new Vector3(0, 0, -0.1f*Input.GetAxis("Horizontal")));
else if( Input.GetKey( KeyCode.LeftArrow ) )
transform.Rotate(new Vector3(0, 0, +0.1f*Input.GetAxis("Horizontal")));
}
为sr_no
。我想获取我插入的数据public int addData(News newsAdd) {
int flag = 0;
String url="";
String cat = newsAdd.getNewsCat();
String language = newsAdd.getNewsLang();
// QueryConstant.newsArbian ="INSERT INTO INTERNET_NEWS(SR_NO,TITLE,NEWS_STATUS,HOME_DISPLAY,HOME_DESC,MAIN_DESC,NEWS_DATE,NEWS_CAT,IMGNEWS_URL) VALUES(seq_news.nextval,?,?,?,?,?,?,?,?)";
flag = getJdbcTemplate().update(
QueryConstant.newsArbian,
new Object[] {
newsAdd.getTitle(),
newsAdd.getStatus(),
newsAdd.getNewsHomePage(),
newsAdd.getNewsDesHom(),
newsAdd.getNewsDesMan(),
newsAdd.getDate(),
newsAdd.getNewsCat(),
url
}
);
return flag;
}
的值,并将此值传递给flag变量。
我该如何完成这项任务?
答案 0 :(得分:0)
您可以使用KeyHolder
类。
请查看此链接http://docs.spring.io/spring/docs/3.1.x/spring-framework-reference/html/jdbc.html#jdbc-simple-jdbc-insert-2
13.5.2 Retrieving auto-generated keys using SimpleJdbcInsert
部分
答案 1 :(得分:0)
尝试GeneratedKeyHolder [docs] :( https://docs.spring.io/spring/docs/2.5.6/javadoc-api/org/springframework/jdbc/support/GeneratedKeyHolder.html) 它将返回上次插入记录的自动生成的ID。