日期:2014-05-16 浏览次数:20380 次
Class.forName("com.mysql.jdbc.Driver"); conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/testing","root","root"); System.out.println(conn); stmt=conn.createStatement(); int row=stmt.executeUpdate ("insert into aa (name) values ('mars')",Statement.RETURN_GENERATED_KEYS); rs = stmt.getGeneratedKeys (); if ( rs.next() ) { int key = rs.getInt(row); System.out.println(key); }