New features from the JDBC-3.0 API in the latest production version of MySQL Connector/J include getGeneratedKeys
which allows users to retrieve auto-increment fields in a non-database-specific way. Auto-increment fields now work with object-relational mapping tools, as well as Enterprise Java Beans (EJB) servers with Container Managed Persistence (CMP) that support JDBC-3.0.
The development version is being refactored to support new features in conjunction with version 4.1 of the MySQL database server, including server-side prepared statements and improved handling of multiple simultaneous character sets, including Unicode in the UCS2 and UTF8 encodings.
Retrieval of Auto Generated Keys:Int rowcount = stmt.executeUpdate ( "insert into LocalGeniusList (name) values ('Karen')"); // insert row
// now get the disk address 鈥?rowid 鈥?for the newly inserted row ResultSet rs = stmt.executeQuery ( "select rowid from LocalGeniusList where name = 'Karen'"); jdbc3.0鏃舵垜浠彲浠ュ湪鎻掑叆涓鏉¤褰曟椂鍚屾椂寰楀埌琛屾暟錛?br />榪樺彲浠ヨ闂埌鑷姩澧為暱鐨勬暟鎹錛?br />Int rowcount = stmt.executeUpdate ("insert into LocalGeniusList (name) values ('Karen'), Statement.RETURN_GENERATED_KEYS); // insert row AND return keyResultSet rs = stmt.getGeneratedKeys (); // key is automatically available
鑰屾湁浜涙暟鎹簱涓嶆敮鎸佽嚜鍔ㄥ闀跨被鍨嬬殑鏁版嵁錛宩dbc3.0涔熺粰鍑虹浉搴旂殑鏀寔:
// insert the row and specify that you want the employee ID returned as the key Int rowcount = stmt.executeUpdate ( "insert into LocalGeniusList (name) values ('Karen'), "employeeID");ResultSet rs = stmt.getGeneratedKeys (); // Karen's employeeID value is now available 瑕佹兂浜嗚В鏇村鐨刯dbc3.0鍙互鍙傝冧笅闈㈢殑緗戠珯:
http://www.datadirect.com/developer/jdbc/topics/jdbc30/index.ssp
http://www-128.ibm.com/developerworks/java/library/j-jdbcnew/
http://www.onjava.com/pub/a/onjava/synd/2001/08/21/jdbc.html?page=3
jdbc4.0鍙傝冪綉绔?br />http://www.theserverside.com/news/thread.tss?thread_id=34465
http://weblogs.java.net/blog/lancea/archive/2006/05/jdbc_40_sqlxml.html
http://java.sys-con.com/read/111252.htm
涓嬭澆jdbc4.0瑙勮寖
http://192.18.108.135/ECom/EComTicketServlet/BEGIN747810F695946413098EEF45230B1F12/-2147483648/1488530847/1/686798/686786/1488530847/2ts+/westCoastFSEND/jdbc-4.0-pr-spec-oth-JSpec/jdbc-4.0-pr-spec-oth-JSpec:2/jdbc4.0-pd-spec.pdf