// Uye güncelleme public void updateUye(Uyeler uye, String param) { Connection connection = null; PreparedStatement preparedStatement = null; String updateString = "UPDATE `uyeler` SET `tc`=?, `ad`=?, `soyad`=?, `meslek`=?,`adres`=?,`telefon`=?,`mail`=?,`kullaniciadi`=?,`sifre`=? WHERE `tc`=?"; try { connection = ConnectionConfiguration.getConnection(); preparedStatement = connection.prepareStatement(updateString); preparedStatement.setString(1, uye.getTc()); preparedStatement.setString(2, uye.getAd()); preparedStatement.setString(3, uye.getSoyad()); preparedStatement.setString(4, uye.getMeslek()); preparedStatement.setString(5, uye.getAdres()); preparedStatement.setString(6, uye.getTelefon()); preparedStatement.setString(7, uye.getMail()); preparedStatement.setString(8, uye.getKullaniciadi()); preparedStatement.setString(9, uye.getSifre()); preparedStatement.setString(10, param); preparedStatement.executeUpdate(); JOptionPane.showMessageDialog(null, "Successful UPDATE"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e.getMessage()); } finally { kapatici(connection, preparedStatement, null); } }
// Uye Kayıt public void insertUye(Uyeler uye) { Connection connection = null; PreparedStatement preparedStatement = null; String query = "INSERT INTO uyeler (`tc`, `ad`, `soyad`, `meslek`,`adres`,`telefon`,`mail`,`kullaniciadi`,`sifre`) VALUES (?,?,?,?,?,?,?,?,?)"; try { connection = ConnectionConfiguration.getConnection(); preparedStatement = connection.prepareStatement(query); preparedStatement.setString(1, uye.getTc()); preparedStatement.setString(2, uye.getAd()); preparedStatement.setString(3, uye.getSoyad()); preparedStatement.setString(4, uye.getMeslek()); preparedStatement.setString(5, uye.getAdres()); preparedStatement.setString(6, uye.getTelefon()); preparedStatement.setString(7, uye.getMail()); preparedStatement.setString(8, uye.getKullaniciadi()); preparedStatement.setString(9, uye.getSifre()); preparedStatement.executeUpdate(); JOptionPane.showMessageDialog(null, "Successful INSERT INTO"); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Kayıtta hata oluştu \n" + e.getMessage()); } finally { kapatici(connection, preparedStatement, null); } }
// Uyeler icin arama metodu public List<Uyeler> selectByUye(String kriter, String param) { List<Uyeler> uyeler = new ArrayList<Uyeler>(); Connection connection = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { connection = ConnectionConfiguration.getConnection(); preparedStatement = connection.prepareStatement("SELECT * FROM uyeler WHERE " + kriter + " LIKE ?"); preparedStatement.setString(1, "%" + param + "%"); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) { Uyeler uye = new Uyeler(); uye.setId(resultSet.getInt("id")); uye.setTc(resultSet.getString("tc")); uye.setAd(resultSet.getString("ad")); uye.setSoyad(resultSet.getString("soyad")); uye.setMeslek(resultSet.getString("meslek")); uye.setAdres(resultSet.getString("adres")); uye.setTelefon(resultSet.getString("telefon")); uye.setMail(resultSet.getString("mail")); uye.setKullaniciadi(resultSet.getString("kullaniciadi")); uye.setSifre(resultSet.getString("sifre")); uyeler.add(uye); } } catch (Exception e) { JOptionPane.showMessageDialog(null, e.getMessage()); } finally { kapatici(connection, preparedStatement, resultSet); } return uyeler; }