[INACTIVE] SQLite and MySQL Tutorial/Library

Discussion in 'Resources' started by alta189, May 12, 2011.

  1. Offline

    alta189

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  2. Online

    Adamki11s

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    This is great alta, thanks :D

    Once I've watched and understood this I'll add it to the wiki along with links and a little writeup.
  3. Online

    Lolmewn BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Thaaank you :p
  4. Offline

    alta189

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Your welcome. Feedback is welcome!!!
  5. Offline

    iPhysX

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Awesome! I'm going to watch these again :)
    You made it seem so easy.
    Really helpful :3
  6. Offline

    alta189

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Thanks, I hope this makes it easier! If you make any plugins using this, I would love to try them out, send me a link!
  7. Offline

    iPhysX

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Im making a plugin where players can purchase a spawn point with a sign :) I'll use it to store their spawns maybe :9
  8. Offline

    alta189

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Awesome, I'll have to try it out
  9. Online

    Adamki11s

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    When testing I keep getting this error:

    Any ideas?
  10. Offline

    alta189

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    What is the query?
  11. Offline

    iPhysX

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    yeah i do get that error but... it doesnt seem to cause any harm :)

    the error is when the mail is recieved or someone types /mail read..
    hope this helps!
  12. Offline

    alta189

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Ill look at this error! Thanks for the feedback.
  13. Online

    Adamki11s

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Yeah, it's just a simple query to write to the database, it shouldn't even return a result set as far as I know.
  14. Online

    Adamki11s

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I also get this error
    While it doesn't seem to cause any problems I like to have an error free console :)
  15. Offline

    iPhysX

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Yes me too i think its trying to create a new db and ignoring that there is a still a db there :) but yeah error free console >= sex

    (That was a joke)
  16. Online

    Adamki11s

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I'm almost finished a reporting plugin with the awesomeness of alta's SQL library and w3schools :D I'll post the link here when finished, should be just under an hour.
  17. Offline

    iPhysX

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Any sneaky info before its released? :)
  18. Offline

    alta189

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Ill add a write to database void and upload it in a minute.
  19. Online

    Adamki11s

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I'm writing the thread now :D

    As for the errors I just commented them out, not idea but looks better :D
  20. Offline

    alta189

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    When are you getting this error? When creating a table or when inserting to the table? Also I updated the lib, look at the change log. I added "insertQuery(String query)" so that you will not get the "Error at SQL Query: query does not return ResultSet" error!
  21. Offline

    alta189

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    First download the lib again to update to the new version of the lib and then in the onEnable() you want to initialize the database like this:
    Code:
                    dbManage = new sqlCore(this.log, this.logPrefix, "mails", pFolder.getPath());
            dbManage.initialize();
    
            if (!dbManage.checkTable("mails")) {
                String query = "CREATE  TABLE mails (  'id' INTEGER PRIMARY KEY,  'sender' VARCHAR(80) NOT NULL ,  'receiver' VARCHAR(80) NOT NULL ,  'message' TEXT NOT NULL ,  'read' INT NOT NULL DEFAULT 0);";
                dbManage.createTable(query);
            }
  22. Online

    Adamki11s

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  23. Offline

    alta189

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @iPhysX
    Btw i edited the fix I gave you to a more reliable one.
  24. Offline

    iPhysX

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @alta189

    thanks, ill put that in later :)
  25. Offline

    iPhysX

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Im not sure.. but..

    Code:
    public void deleteMail (Player player) throws SQLException {
    
                    String query = "DELETE id, sender, receiver, message, read FROM mails WHERE receiver = '" + player.getName() + "';";
    
                    ResultSet result = plugin.dbManage.sqlQuery(query);
    
                   if (result == null) {
                       plugin.log.info(plugin.logPrefix + "No result at delete mail!");
                       return;
                   }
    and

    Code:
    if (args[0].equalsIgnoreCase("delete") && player != null) {
                                 if ((args.length == 1)) {
                                     try{
    
                                     if (mmServer.getUnreadCount(player.getName()) >= 1) {
                                        mmServer.deleteMail(player);
                                    } else {
                                        player.sendMessage(ChatColor.RED + "No Messages to delete!");
                                    }
                                } catch (SQLException e) {
    
                                    e.printStackTrace();
                                }
                                 } else {
                                     player.sendMessage(ChatColor.RED + "Deleting mail was unsucessful!");
    
                                 }
    might be good for deleting mail, i havent worked with SQLite before and this is just speculation really :)

    and to reload the database for some reason :)

    Code:
    if (args[0].equalsIgnoreCase("reload") && player != null) {
                                     if ((args.length == 1)) {
                                         if(player.isOp()){
                                             dbManage.close();
                                             System.out.println("[Mail] Database Closed.");
                                             dbManage.initialize();
                                             System.out.println("[Mail] Database Loaded.");
                                             player.sendMessage(ChatColor.GREEN + "[Mail] Database has been reloaded");
                                         }else {
                                             player.sendMessage(ChatColor.RED + "[Mail] Only Admins can reload the database");
                                         }
                                     }
  26. Offline

    alta189

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Thanks I'll add these when I update the tutorial, I am going to make a text tutorial instead this time so that I dont have to keep remaking, reuploading, and reposting the tutorial! :D
  27. Offline

    iPhysX

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    No problems, i think they should work, im just sorting out my onCommand because i killed it somehow :D

    ahh yeah text would be easier to manage :)
    you should do one on.. onCommand etc? and sending messages, broadcasting messages?
    because that would be great, i ALWAYS screw up the onCommand and its bugging me xD
  28. Online

    Adamki11s

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    My tutorial might have some of that stuff ;)
  29. Offline

    iPhysX

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Well, great :p that would be nice! I would make one xD.. but HA!
    -_-
  30. Offline

    alta189

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Updated to version 1.3, documentation will be uploaded soon, but the link is already updated!

Share This Page