Advertisement
Guest User

Untitled

a guest
May 16th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. import org.jibble.pircbot.*;
  2. import java.sql.*;
  3.  
  4. public class MyBot extends PircBot {
  5.  
  6. public MyBot() {
  7. this.setName("anrki2");
  8. }
  9.  
  10. public void onMessage(String channel, String sender,
  11. String login, String hostname, String message) {
  12. if (message.equalsIgnoreCase("time")) {
  13. String time = new java.util.Date().toString();
  14. sendMessage(channel, sender + ": The time is now " + time);
  15. }
  16. if (message.equalsIgnoreCase("test")) {
  17. Connection con = null;
  18. String url = "jdbc:mysql://localhost:3306/";
  19. String db = "gazelle";
  20. String driver = "com.mysql.jdbc.Driver";
  21. String user = "root";
  22. String pass = "PASSWORD";
  23. try{
  24. Class.forName(driver);
  25. con = DriverManager.getConnection(url+db, user, pass);
  26. try{
  27. DatabaseMetaData dbm = con.getMetaData();
  28. String[] types = {"TABLE"};
  29. ResultSet rs = dbm.getTables(null,null,"%",types);
  30. System.out.println("Table name:");
  31. while (rs.next()){
  32. String table = rs.getString("TABLE_NAME");
  33. System.out.println(table);
  34. sendMessage(channel, (table));
  35. con.close();
  36. }
  37. }
  38. catch (SQLException s){
  39. }
  40. }
  41. catch (Exception e){
  42. e.printStackTrace();
  43. }
  44. }
  45. }
  46. public void onJoin(String channel, String sender,
  47. String login, String hostname) {
  48. if (sender.equalsIgnoreCase(getNick())) {
  49. } else {
  50. sendMessage(channel, "Hello " + sender + "!");
  51. }
  52. }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement