Guest User

Untitled

a guest
Jun 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. public void removeBugReport(int number) {
  2. try {
  3. Connection con = (Connection) DatabaseConnection.getConnection();
  4. PreparedStatement pse = (PreparedStatement) con.prepareStatement("DELETE FROM bugreports WHERE id = ?");
  5. pse.setInt(1, number);
  6. pse.executeUpdate();
  7. pse.close();
  8. } catch (Exception e) {
  9. System.err.println("failed to removeBugReport");
  10. }
  11. }
  12.  
  13. public String getBugReport(int number) {
  14. try {
  15. Connection con = (Connection) DatabaseConnection.getConnection();
  16. PreparedStatement ps = (PreparedStatement) con.prepareStatement("SELECT * FROM bugreports WHERE id = ?");
  17. ps.setInt(1, number);
  18. ResultSet rs = ps.executeQuery();
  19. return rs.getInt("id") +". "+ rs.getString("charname") +" : "+ rs.getString("message");
  20. } catch (Exception e) {
  21. return "Something went wrong";
  22. }
  23. }
  24.  
  25. public String viewBugReports() {
  26. String text = (isGM() ? "Click a bug report once to remove it (GM Mode)\r\n\r\n" : "") +"Beta Testers's report list: ";
  27. int count = 0;
  28. try {
  29. Connection con = (Connection) DatabaseConnection.getConnection();
  30. PreparedStatement ps = (PreparedStatement) con.prepareStatement("SELECT * FROM bugreports");
  31. ResultSet rs = ps.executeQuery();
  32. rs.first();
  33. while (rs.next()) {
  34. count++;
  35. if (isGM())
  36. text += "#L"+ rs.getInt("id") +"#"+ rs.getInt("id") +". "+ rs.getString("charname") +" : "+ rs.getString("message") +".#k\r\n";
  37. else
  38. text += rs.getInt("id") +". "+ rs.getString("charname") +" : "+ rs.getString("message") +".";
  39. }
  40. return text;
  41. } catch (Exception ex) {
  42. System.err.println("failed to viewBugReports.");
  43. return "Something went wrong";
  44. }
  45. }
  46.  
  47. public void bugReport(String message) {
  48. try {
  49. PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("INSERT INTO `bugreports` (`charname`, `message`) VALUES (?, ?)");
  50. ps.setString(1, getName());
  51. ps.setString(2, message);
  52. ps.execute();
  53. ps.close();
  54. } catch (SQLException se) {
  55. System.out.println("Failed to add bugReport. Reason: "+ se.getCause());
  56. }
  57. }
Add Comment
Please, Sign In to add comment