[INACTIVE] SQLite and MySQL Tutorial/Library

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

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

    Lolmewn

    try to put it in another folder, it worked for me.
     
  2. Offline

    Jayjay110

    really?

    EDIT:
    Didnt work, its in /data, no change
     
  3. Offline

    Lolmewn

    Then I have no clue.
     
  4. Offline

    alta189

    MySQL database already has to be made, sorry haven't found a way for it to make the database yet :D
     
  5. Offline

    totokaka

    how can i check if a player is added to the database? so i dont add him twice?
     
  6. Offline

    alta189

    Use a select query. w3schools.com
     
  7. Offline

    totokaka

  8. Offline

    Jayjay110

    wat about http://www.w3schools.com/sql/sql_create_db.asp ?

    Anyway I ffigured out my error, it was to do with the primary key, needs its own field
     
  9. Offline

    alta189

    It has to do with the way I connect. The way I have it connecting it needs to have the database already created. I'll figure it out. :D
     
  10. Offline

    Jayjay110

    oh ok ;)
     
  11. Offline

    alta189

    did you like the update?
     
  12. Offline

    Lolmewn

    something like this?
    Code:
    query = "SELECT * FROM skillz WHERE player = '" + p + "'";
                ResultSet res = db.sqlQuery(query);
     
  13. Offline

    Tagette

    Yes then:
    Code:
    boolean exists = res.next();
     
  14. Offline

    Lolmewn

    Because it says this:
    Code:
    19:49:11 [INFO] Lolmewn [/127.0.0.1:28466] logged in with entity id 25 at (-220.6875, 66.0, -154.40625)
    19:49:11 [SEVERE] Could not pass event PLAYER_JOIN to Skillz
    java.lang.NullPointerException
            at nl.lolmen.Skillz.SkillzPlayerListener.onPlayerJoin(SkillzPlayerListener.java:54)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:243)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:310)
            at net.minecraft.server.ServerConfigurationManager.c(ServerConfigurationManager.java:117)
            at net.minecraft.server.NetLoginHandler.b(NetLoginHandler.java:96)
            at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:74)
            at net.minecraft.server.Packet1Login.a(SourceFile:43)
            at net.minecraft.server.NetworkManager.b(NetworkManager.java:215)
            at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:40)
            at net.minecraft.server.NetworkListenThread.a(SourceFile:91)
            at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:396)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:308)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    Line 54 is this: ResultSet res = db.sqlQuery(query);
    The query is: "SELECT * FROM skillz WHERE player = '" + p + "'";

    Oh wait I know why that happens, it's because I'm in another class and the dbManager hasn't been filled yet.

    Now I'm getting this:
    Code:
    String query;
                Skillz.log.info(p);
                query = "SELECT * FROM skillz WHERE player='" + p + "'";
                ResultSet res = db.sqlQuery(query);
    Code:
    21:19:06 [INFO] Lolmewn
    21:19:06 [SEVERE] Could not pass event PLAYER_JOIN to Skillz
    java.lang.NullPointerException
            at nl.lolmen.sqllitelib.sqlCore.sqlQuery(sqlCore.java:62)
            at nl.lolmen.Skillz.SkillzPlayerListener.onPlayerJoin(SkillzPlayerListener.java:56)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:243)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:310)
            at net.minecraft.server.ServerConfigurationManager.c(ServerConfigurationManager.java:117)
            at net.minecraft.server.NetLoginHandler.b(NetLoginHandler.java:96)
            at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:74)
            at net.minecraft.server.Packet1Login.a(SourceFile:43)
            at net.minecraft.server.NetworkManager.b(NetworkManager.java:215)
            at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:40)
            at net.minecraft.server.NetworkListenThread.a(SourceFile:91)
            at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:396)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:308)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    Line 56 is ResultSet res.

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

    alta189

    Send me the source :D
     
  16. Offline

    Lolmewn

  17. Offline

    niccholaspage

    This is amazing & really helpful.
     
  18. Offline

    Lolmewn

    Agreed. Btw, does the MySQL stuff work pretty much the same as the Sql, except for the onEnable? (I got that part working already)
     
    Jayjay110 likes this.
  19. Offline

    alta189

    yes are you still having errors
     
    Jayjay110 likes this.
  20. Offline

    Jayjay110

    Umm, the only error I can see now is this, it happens sometimes just at random, or when I reload the server, btw im not even trying to access the database at this point?:
    2011-05-29 20:46:16 [WARNING] [MyPlugin] Error at SQL Query: cannot commit transaction - SQL statements in progress
    2011-05-29 20:46:16 [WARNING] [MyPlugin] Error at SQL Query: query does not return ResultSet

    I believe it occurs when I do this:

    String query = "INSERT INTO 'blocks' (Name, x, y, z, World) VALUES ('" + plugin.con.playerkey.get(player) +"', " + block.getX() + ", " + block.getY() + ", " + block.getZ() + ", '" + block.getWorld().getName() + "');";
    if (plugin.con.MySQL) {
    try {
    plugin.manageMySQL.insertQuery(query);
    } catch (MalformedURLException e) {
    e.printStackTrace();
    } catch (InstantiationException e) {
    e.printStackTrace();
    } catch (IllegalAccessException e) {
    e.printStackTrace();
    }
    } else {
    plugin.manageSQLite.insertQuery(query);
    }


    This: plugin.con.playerkey.get(player)
    Is the name from the onCommandArgs
     
  21. Offline

    alta189

    Reloading will cause errors in your onDisable, close the connection
     
  22. Offline

    Jayjay110

    I thought so I just didnt see in your owners file, any closing so I guessed it was automatic :p

    I am currently modifiying your code if that is ok with you, I have added a new connection checker to test if there is any databases yet :) and then It adds them, pm me or post and u can add it to ur lib :D

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

    Lolmewn

    Yeah, the same. Was just wondering if MySQL worked the same.
     
  24. Offline

    Jayjay110

    You want the auto create db code?, I think it actually checks the database better too... No offence alta :p
     
  25. Offline

    Lolmewn

    Im not quite sure what you mean, so what do you mean?
     
  26. Offline

    Jayjay110

    Ive managed to put a check in there so It can check if the database for mysql is made, if not it tries to create it then load the plugin :)
     
  27. Offline

    Lolmewn

    Oh like that :p Btw, this is my 1001th post xD
     
  28. Offline

    Jayjay110

    Lol 1001th post

    p.s: what does Oh like that :p mean? lol
     
  29. Offline

    Lolmewn

    It means something like: Oh, is THAT what you mean!
     
  30. Offline

    Jayjay110

    Oh lol, it just didnt seem worded right :p
     
Thread Status:
Not open for further replies.

Share This Page