如何在Java中的单个服务中调用多个URL?

时间:2019-05-14 14:33:32

标签: java if-statement jdbc

DBConn dBConn = new DBConn();
PreparedStatement prepareStatement;

Connection con = dBConn.getDBConnectionForPro();
prepareStatement = con.prepareStatement("SELECT * FROM TBL_MASCONFIGTTB WHERE SERVICE_NAME=GUPSHUP AND VALUE=TRUE");

if (prepareStatement.equals("true")) {
    System.out.println(GenerateLinkDaoImpl.sendOTP("90xxxxxxxx", smsBody));
}
else {
    System.out.println(GenerateLinkDaoImpl.SendSms("90xxxxxxxx", smsBody));
}

1 个答案:

答案 0 :(得分:0)

您不能在PreparedStatement上使用布尔值,而需要首先使用ResultSet。 尝试使用下面的代码。

DBConn dBConn = new DBConn();
PreparedStatement prepareStatement = null;
ResultSet rs = null;

Connection con = dBConn.getDBConnectionForPro();
prepareStatement = con.prepareStatement("SELECT * FROM TBL_MASCONFIGTTB WHERE SERVICE_NAME=GUPSHUP AND VALUE=TRUE");
rs = prepareStatement.executeQuery();

if (rs.next()) {
    System.out.println(GenerateLinkDaoImpl.sendOTP("90xxxxxxxx", smsBody));
}
else {
    System.out.println(GenerateLinkDaoImpl.SendSms("90xxxxxxxx", smsBody));
}