@Override public Client save(Client client) throws DAOException { Connection connection; try { connection = JDBCUtil.getConnection(); PreparedStatement prepareStatement = connection.prepareStatement( "INSERT INTO Client (nomcl,adresse,ville) VALUES (?,?,?)", Statement.RETURN_GENERATED_KEYS); prepareStatement.setString(1, client.getNomClient()); prepareStatement.setString(2, client.getAdresse()); prepareStatement.setString(3, client.getVille()); prepareStatement.executeUpdate(); ResultSet keys = prepareStatement.getGeneratedKeys(); keys.next(); client.setCodeClient(keys.getInt(1)); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | SQLException e) { throw new DAOException(e.getMessage(), e.getCause()); } return client; }