use of java.sql.ResultSet in project Openfire by igniterealtime.
the class Config method createCallRecord.
public static void createCallRecord(String username, String addressFrom, String addressTo, long datetime, int duration, String calltype) {
if (sipPlugin) {
Log.info("createCallRecord " + username + " " + addressFrom + " " + addressTo + " " + datetime);
String sql = "INSERT INTO ofSipPhoneLog (username, addressFrom, addressTo, datetime, duration, calltype) values (?, ?, ?, ?, ?, ?)";
Connection con = null;
PreparedStatement psmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
psmt = con.prepareStatement(sql);
psmt.setString(1, username);
psmt.setString(2, addressFrom);
psmt.setString(3, addressTo);
psmt.setLong(4, datetime);
psmt.setInt(5, duration);
psmt.setString(6, calltype);
psmt.executeUpdate();
} catch (SQLException e) {
Log.error(e.getMessage(), e);
} finally {
DbConnectionManager.closeConnection(rs, psmt, con);
}
}
}
use of java.sql.ResultSet in project Openfire by igniterealtime.
the class Config method processRegistrations.
private void processRegistrations() {
String sql = "SELECT username, sipusername, sipauthuser, sipdisplayname, sippassword, sipserver, enabled, status, stunserver, stunport, usestun, voicemail, outboundproxy, promptCredentials FROM ofSipUser ORDER BY USERNAME";
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = DbConnectionManager.createScrollablePreparedStatement(con, sql);
ResultSet rs = pstmt.executeQuery();
DbConnectionManager.scrollResultSet(rs, 0);
while (rs.next()) {
ProxyCredentials credentials = read(rs);
try {
InetAddress inetAddress = InetAddress.getByName(credentials.getHost());
registrars.add(credentials.getHost());
registrations.add(credentials);
Log.info(String.format("VoiceBridge adding SIP registration: %s with user %s host %s", credentials.getXmppUserName(), credentials.getUserName(), credentials.getHost()));
} catch (Exception e) {
Log.info(String.format("processRegistrations Bad Address %s ", credentials.getHost()));
}
}
rs.close();
pstmt.close();
con.close();
} catch (SQLException e) {
Log.info("processRegistrations " + e);
}
}
use of java.sql.ResultSet in project Openfire by igniterealtime.
the class SipAccountDAO method getAccountByUser.
public static SipAccount getAccountByUser(String username) {
String sql = "SELECT username, sipusername, sipauthuser, sipdisplayname, sippassword, sipserver, enabled, " + "status, stunserver, stunport, usestun, voicemail, outboundproxy, promptCredentials FROM ofSipUser " + "WHERE username = ? ";
SipAccount sipAccount = null;
Connection con = null;
PreparedStatement psmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
psmt = con.prepareStatement(sql);
psmt.setString(1, username);
rs = psmt.executeQuery();
if (rs.next()) {
sipAccount = read(rs);
}
} catch (SQLException e) {
Log.error(e.getMessage(), e);
} finally {
DbConnectionManager.closeConnection(rs, psmt, con);
}
return sipAccount;
}
use of java.sql.ResultSet in project Openfire by igniterealtime.
the class SipAccountDAO method getUserCount.
public static int getUserCount() {
int count = 0;
String sql = "SELECT count(*) FROM ofSipUser";
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
count = rs.getInt(1);
}
rs.close();
} catch (SQLException e) {
Log.error(e.getMessage(), e);
} finally {
try {
if (pstmt != null) {
pstmt.close();
}
} catch (Exception e) {
Log.error(e.getMessage(), e);
}
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
Log.error(e.getMessage(), e);
}
}
return count;
}
use of java.sql.ResultSet in project head by mifos.
the class AccountingDaoImpl method getTenTxnDate.
@Override
public final List<LocalDate> getTenTxnDate(LocalDate startDate, LocalDate endDate, Integer offset) {
Object[] parameter = new Object[] { startDate.toString(), endDate.toString(), offset };
List<LocalDate> tenTrxn = jdbcTemplate.query(getTenTrxDataQuery(), parameter, new ParameterizedRowMapper<LocalDate>() {
@Override
public LocalDate mapRow(ResultSet rs, int rowNum) throws SQLException {
return new LocalDate(rs.getDate(1).getTime());
}
});
return tenTrxn;
}
Aggregations