if exists certain line in sql table java condition code example
Example: if exists certain line in sql table java condition
public void ftpTableCheck(String host, String port, String username, String password) {
try {
String query = "SELECT (count(*) > 0) as found FROM ftp WHERE Host LIKE ? AND Username LIKE ?";
PreparedStatement pst = conn.prepareStatement(query);
pst.setString(1, host);
pst.setString(2, username);
try (ResultSet rs = pst.executeQuery()) {
if (rs.next()) {
boolean found = rs.getBoolean(1);
if (found) {
} else {
}
}
}
} catch (SQLException e) {
e.printStackTrace();
}
}