Get last inserted auto increment id in mysql

前端 未结 6 842
你的背包
你的背包 2020-12-09 10:10

I am trying to get the mysql command like mysql_insert_id(); which retrieve the last inserted row\'s auto_increment id. What can I do to get it in Java?

rs =         


        
6条回答
  •  长情又很酷
    2020-12-09 10:54

    Try using an alias

    rs = st.executeQuery("select last_insert_id() as last_id from schedule");
    lastid = rs.getString("last_id");
    

提交回复
热议问题