Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.jibble.pircbot.*;
- import java.sql.*;
- public class MyBot extends PircBot {
- public MyBot() {
- this.setName("anrki2");
- }
- public void onMessage(String channel, String sender,
- String login, String hostname, String message) {
- if (message.equalsIgnoreCase("time")) {
- String time = new java.util.Date().toString();
- sendMessage(channel, sender + ": The time is now " + time);
- }
- if (message.equalsIgnoreCase("test")) {
- Connection con = null;
- String url = "jdbc:mysql://localhost:3306/";
- String db = "gazelle";
- String driver = "com.mysql.jdbc.Driver";
- String user = "root";
- String pass = "PASSWORD";
- try{
- Class.forName(driver);
- con = DriverManager.getConnection(url+db, user, pass);
- try{
- DatabaseMetaData dbm = con.getMetaData();
- String[] types = {"TABLE"};
- ResultSet rs = dbm.getTables(null,null,"%",types);
- System.out.println("Table name:");
- while (rs.next()){
- String table = rs.getString("TABLE_NAME");
- System.out.println(table);
- sendMessage(channel, (table));
- con.close();
- }
- }
- catch (SQLException s){
- }
- }
- catch (Exception e){
- e.printStackTrace();
- }
- }
- }
- public void onJoin(String channel, String sender,
- String login, String hostname) {
- if (sender.equalsIgnoreCase(getNick())) {
- } else {
- sendMessage(channel, "Hello " + sender + "!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement