Code example for PreparedStatement

Methods: executegetGeneratedKeys

0
 
		try { 
			statement = connection.prepareStatement(String.format("INSERT INTO documents(id, doc_name) values(DEFAULT, '%s');", documentPath),
					Statement.RETURN_GENERATED_KEYS);
 
			statement.execute();
 
			ResultSet resultSet = statement.getGeneratedKeys();
 
			if (resultSet != null && resultSet.next()) {
				newDocumentId = resultSet.getInt(1);
			} 
 
			saxParser.parse(new File(documentPath), this);
		} catch (Exception e) {
			throw new RuntimeException(e);
		} 
	} 
 
	@Override 
Stop searching for code, let great code find you!  Add Codota to your java IDE