how to get last insert id by java

	public static int getLastInsertID(Connection conn, String statment)throws SQLException {
		int lastInsertedId = -1;
		PreparedStatement ps = conn.prepareStatement(statment,PreparedStatement.RETURN_GENERATED_KEYS);

		ResultSet rskey = ps.getGeneratedKeys();
		if (rskey != null && {
			lastInsertedId = rskey.getInt(1);
		return lastInsertedId;

About lorddisk

WebCenter Content, WebCenter Portal, WebCenter Sites,Weblogic, Identity and Access Management (IAM),SSO,OAM,OIM,OAAM,OUD, OPAM,OID, OVD ,Oracle API Gateway ,OBIEE,OEDQ, Oracle ADF, Oracle SOA,J2EE, CackePHP ,PHP,J2SE,J2EE,Spring,Hibernate,JQuery,CSS,Java Script ,Joomla,Drupal,Worpress
This entry was posted in java, jdbc, mysql and tagged , , , . Bookmark the permalink.