News:

So the widespread use of emojis these days kinda makes forum smileys pointless, yeah?

Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - ghostofkc

#1
Academic / School / Re: Post your fall courses
June 20, 2009, 10:08:01 AM
Enrolled for - 2009 Fall
Course   Title   
ENHS-603-40   SURVEY OF ENVIRON HEALTH
EPID-603-01   EPIDEMIOLOGIC METHODS
TRMD-605-01   MEDICAL HELMINTHOLOGY
TRMD-607-01   MEDICAL PROTOZOOLOGY
TRMD-609-01   PARASITOLOGY LAB
TRMD-617-01   IMMUNOLOGY
TRMD-702-01   PARASITOLOGY SEMINAR

o.O
#2
JavaOp Support Archive / Plug-in using JDBC
April 17, 2009, 02:06:57 PM
I started off trying to make my own bot to do some semi specialized things... but I am retarded. Then I found your program.
So I am having issues with making JDBC work in the context of a plug-in for JavaOp2.

Admittedly I suck at java but, I have the connection working and performing queries outside of a plug-in. I looked on the forum and pervious posts about jdbc use in a plugin (there is one from 05) but they do not have any conclusions.


The error I get is "com.mysql.jdbc.Driver" which I understand (I think) to be a class path issue. But, I have included and referenced it just like I did in the standalone script (where it works).


So I guess the question is... what is different about using jdbc in the context of a plug-in / what am I fucking up.

        ////////////////////////////////////////////////////////////////////////////////////////////////////
        else if(command.equalsIgnoreCase("playgame"))
        {
        //error catch
        if(args.length == 0)
                throw new CommandUsedImproperly("Error.", user, command);
        //end error catch
       
        Connection conn = null;

            try
            {
                String userName = "USERNAME";
                String password = "PASSWORD";
                //String url = "jdbc:mysql://localhost/ladder";
                String url = "jdbc:mysql://knightsofchaos.org/dschott_ladder";
                Class.forName ("com.mysql.jdbc.Driver").newInstance ();
                conn = DriverManager.getConnection (url, userName, password);
                out.sendTextUserPriority(user, "Database connection established.", loudness, PRIORITY_LOW);
                ///////////////////////////////////////////////////////////////////////////////////////////////////
                //query perform
                Statement stmt = conn.createStatement();
                ResultSet rs;
                rs = stmt.executeQuery("SELECT id FROM users WHERE alias = 'Creed'"); //test line
                while ( rs.next() ) {
                    String id = rs.getString("id");
                    out.sendTextUserPriority(user, id, loudness, PRIORITY_LOW);
                   
                    //converting from sting to int for id so checks can be done
                    int idNum = Integer.valueOf(id).intValue();
                    ///////////////////////////////////////////////////////////////////////////////////////////////////
                    if (idNum == 0)
                    {
                    out.sendTextUserPriority(user, "sorry! username does not exist.", loudness, PRIORITY_LOW);
                    }
                }
                conn.close();
                //end query preform
               
            }
            catch (Exception e)
            {
            /*
            * this is erroring because jdbc is not loading or something. /cry sad panda - 4/17/2009 ghost
            */
            out.sendTextUserPriority(user, "Cannot connect to database server.", loudness, PRIORITY_LOW);
            out.sendTextUserPriority(user, e.getMessage(), loudness, PRIORITY_LOW);
                //System.err.println ("Cannot connect to database server");
                //System.err.println(e.getMessage());
            }
            //this trys to close the conection after the query is done
            finally
            {
                if (conn != null)
                {
                    try
                    {
                        conn.close ();
                       
                        //this is active for debuging will not talkie once it is working.
                        out.sendTextUserPriority(user, "Database connection terminated.", loudness, PRIORITY_LOW);
                    }
                    catch (Exception e) { /* ignore close errors */ }
                }
            }
            //end connection close
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////



below links are to all of the code if anyone cares
http://www.knightsofchaos.org/bot/plugin.txt -  jdbc connection plugin for javaop2
http://www.knightsofchaos.org/bot/standalone.txt - jdbc connection

I know this is probably a lame question but I cant find an answer to this on google or anything... probably because I don't know what the problem is so I am looking up the wrong thing but what ever.


Thanks for the help.