public void recordUserName(String username) {
String insert = "INSERT INTO " + Const.USER_TABLE + "(" + Const.USER_USERNAME + ")" + "VALUES(" + username + ")";
try {
PreparedStatement prSt = getDbconnection().prepareStatement(insert);
prSt.execute();
} catch (SQLException throwables) {
throwables.printStackTrace();
}
}
DatabaseHandler databaseHandler = new DatabaseHandler();
String username = update.getMessage().getChat().getFirstName();
databaseHandler.recordUserName(username);
public static final String USER_USERNAME = "username";
public void spamMsg(String chatId, String text) {
SendMessage sendMessage = new SendMessage();
sendMessage.enableMarkdown(true);
sendMessage.setChatId(chatId);
sendMessage.setText(text);
try {
execute(sendMessage);
} catch (TelegramApiRequestException e) {
e.getApiResponse(); // < ----- тут ошибка ловится
} catch (TelegramApiException e) {
e.printStackTrace();
}
}