如何使JDBC插入數據的時候返回自動增加的主鍵值

一般插入數據時的代碼以下:java ... String sql = "insert into table (name) values(?)"; PreparedStatement pstmt = conn.prepareStatement(sql); // 若是使用靜態的SQL,則不須要動態插入參數 pstmt.setString(1, name); pstmt.executeUpdate
相關文章
相關標籤/搜索