[INACTIVE] SQLite and MySQL Tutorial/Library

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

Thread Status:
Not open for further replies.
  1. Offline

    alta189

  2. Offline

    Adamki11s

    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. Offline

    Lolmewn Retired Staff

    Thaaank you :p
     
  4. Offline

    alta189

    Your welcome. Feedback is welcome!!!
     
  5. Offline

    iPhysX

    Awesome! I'm going to watch these again :)
    You made it seem so easy.
    Really helpful :3
     
  6. Offline

    alta189

    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

    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

    Awesome, I'll have to try it out
     
  9. Offline

    Adamki11s

    When testing I keep getting this error:

    Any ideas?
     
  10. Offline

    alta189

    What is the query?
     
  11. Offline

    iPhysX

    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

    Ill look at this error! Thanks for the feedback.
     
  13. Offline

    Adamki11s

    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.

    I also get this error
    While it doesn't seem to cause any problems I like to have an error free console :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 16, 2016
  14. Offline

    iPhysX

    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)
     
  15. Offline

    Adamki11s

    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.
     
  16. Offline

    iPhysX

    Any sneaky info before its released? :)
     
  17. Offline

    alta189

    Ill add a write to database void and upload it in a minute.
     
  18. Offline

    Adamki11s

    I'm writing the thread now :D

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

    alta189

    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!

    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);
            }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 16, 2016
  20. Offline

    Adamki11s

  21. Offline

    alta189

    @iPhysX
    Btw i edited the fix I gave you to a more reliable one.
     
  22. Offline

    iPhysX

    @alta189

    thanks, ill put that in later :)

    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");
                                         }
                                     }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 16, 2016
  23. Offline

    alta189

    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
     
  24. Offline

    iPhysX

    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
     
  25. Offline

    Adamki11s

    My tutorial might have some of that stuff ;)
     
  26. Offline

    iPhysX

    Well, great :p that would be nice! I would make one xD.. but HA!
    -_-
     
  27. Offline

    alta189

    Updated to version 1.3, documentation will be uploaded soon, but the link is already updated!
     
  28. Offline

    Adamki11s

    Thank you very much :D
     
  29. Offline

    fregaPT I steal plugins as my own

    Thanks !
    I'll be using this soon as possible! :)
     
  30. Offline

    alta189

    Ok, The tutorial is a little out dated, I think MineMail source may be a little updated though, if you have any quesstions the easiest way is either through bukkit, or skype! Good luck. I will have some documentation up soon! I have alot of exams to finish this week, so my time is pressed!
     
Thread Status:
Not open for further replies.

Share This Page