[LIB] SQLibrary - Database wrappers for all database engines

Discussion in 'Resources' started by PatPeter, Aug 26, 2011.

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

    PatPeter

    alta189 wrote retry and retryResult. I knew that retryResult caused an infinite loop and originally commented it out, but then I added it back in for what I assume was to fix it only to forget about it. Thanks for the code rewrite, I'll try to get it in the next version.
     
  2. Offline

    ceulemans

    I'm getting the "Too many connections", can you please post the update (or just put it on github).
     
  3. Offline

    unv_annihlator

    @PatPeter
    I'm getting a weird issue. So when I make a query to insert a new entry it doesn't toss any error, it returns the data when requested. But in my database I don't see the entry? Any idea behind this?

    Code I'm using to insert.
    plugin.db.query("INSERT INTO kblb VALUES ('"+sender.getName()+"', 0, 0, 0.00)");

    or perhaps it's returning a defaulted value? Also do names with an underscore in it make for difficulties?

    Edit: Got everything working now it seems. But in-case you look at this before I work it out. How should I do a Top 10 using a Order by also. I tried TOP but it gave me a query error.

    EDIT 2: Instead of trying to do both I just did an ORDER BY and then did an if statement inside a loop making it only grab so many rows. Might not be the most efficient way though so if you have a better solution feel free to let me know :D
     
  4. Offline

    Andreas Brisner

    Question:
    When using
    PreparedStatement ps = mysql.prepare(String);
    How do you query it? the mysql.query takes string as input.

    Or have I misunderstood how to even use this library?
     
  5. Offline

    floorman

    I would watch the video but it is private for some reason...
     
  6. Offline

    iffa

    Wait, where's the download?
     
  7. Offline

    DrAgonmoray

    PatPeter
    Are you still working on this?
    Can I do queries on an async task?
     
  8. Offline

    Jigabot

    Could someone post a link to the download?

    edit: nevermind grabbed it out of fuzzyslippers42's github
     
  9. Offline

    ZephyrSigmar

    PatPeter
    I found lot of errors in the SQLite library :/
    It's always locked,i have manually close the resultsets and connections,and the retryQuery and retryResult crash the server,because they're making infinite loops.
     
  10. Offline

    946ben

    Where is the download link?
    Even if you're not working on this project you can give us the link

    Excuse my very very bad English :D It's very bad i know
     
    EarlyLegend likes this.
  11. Offline

    moose517

    Since this seems to be bugged anybody have suggestions for other similar SQLite/MySQL "wrappers"
     
  12. Offline

    PatPeter

    Yeah, sorry everyone. I fixed all of the things I broke in dumb attempts to fix a problem on Linux servers. The problem is I was notified that my code should be on GitHub (why the download link is no longer there). Around the time I was putting my code on GitHub I lost ~200 tabs to an update and haven't worked on it since, not to mention the mound of work I have to do IRL.

    I might be able to upload the long-overdue fix this weekend, no promises though.
     
    robxu9 and EarlyLegend like this.
  13. Offline

    moose517

    i would really appreciate the update. I'm waiting to release my plugin till i have sqlite working and since its known to be bugged well.... yeah. LOL.
     
  14. Offline

    EarlyLegend

    And me - I am attempting to learn to use databases and this would be of tremendous help to me :p Otherwise I'll have to carry on my struggle with MySQL or turn to flatfiles :L Thanks! (Also if you could quote my post if and when you do get an update out so I can find out ASAP!) :D
     
  15. Offline

    PatPeter

    UPDATE: I've finished committing all prior versions of the library here: https://github.com/PatPeter/SQLibrary

    I'll update GitHub with the working version in about an hour, I have to go AFK.
     
  16. Offline

    wouter0100

    Okay, Thanks.
     
  17. Offline

    PatPeter

    What problems are you and everyone else getting with the current download?
     
  18. Offline

    wouter0100

    Lagg problems, but that was with the old libary. (I heard things about Main Server Thread??)
     
  19. Offline

    PatPeter

    MySQL or SQLite? Test it with the GitHub version.
     
  20. Offline

    wouter0100

    MySQL, But nevermind, created my own MySQL connection things xd
     
  21. Offline

    PatPeter

    Are you still receiving this error? If you are, make sure to close your results when you finish with them.

    Is it working now?

    Hmm, I may have possibly not added a method that allows you to actually execute prepared methods, will look into.

    The video is outdated for a very old version of the library.

    First post.

    You mean threaded?

    He's probably running the most up-to-date copy, I'll have to tell him to update it when I fix these bugs.

    I'm working on a fix for the retry methods, hopefully I'll push it this weekend.

    It's on the first post of this thread now.

    No.

    Download is up. Report any bugs.

    Message quoted. Start testing!
     
    EarlyLegend likes this.
  22. Offline

    EarlyLegend

    Woo! Will do! :D
     
  23. Offline

    unv_annihlator

    If you released a new version then I haven't tested it. Did you attempt to fix it so TOP works, and would I be able to use TOP and a Sort?

    If you didn't release a new version then like I said I just didn't use TOP.
     
  24. Offline

    EarlyLegend

    Been messing around with it and it seems pretty bugless ;) Thanks! :D This has made SQLite soooo much easier :D
     
  25. Offline

    DrAgonmoray

    ..yeah.
     
  26. Offline

    EarlyLegend

    (SOLVED)
    Hey I'm probably noobing out here, but my query(String query) method in the SQLite.java file only contains the case SELECT and not any other types of query :L Is that correct? If so how would I, for example, use DELETE or INSERT, especially as the query(...) method is "public ResultSet query(...)" so... help! Thanks D:

    PHP:
    @Override
        
    public ResultSet query(String query) {
            
    Connection connection null;
            
    Statement statement null;
            
    ResultSet result null;
       
            try {
                
    connection this.open();
                
    statement connection.createStatement();
           
                switch (
    this.getStatement(query)) {
                    case 
    SELECT:
                        
    result statement.executeQuery(query);
                        return 
    result;
                   
                    
    //I just added this but it is probably wrong!
                    /*case DELETE:
                        statement.executeQuery(query);
                        return null;*/
                   
                    
    default:
                        
    statement.executeQuery(query);
                        return 
    result;
                }
            } catch (
    SQLException ex) {
                if (
    ex.getMessage().toLowerCase().contains("locking") || ex.getMessage().toLowerCase().contains("locked")) {
                    return 
    retryResult(query);
                    
    //this.writeError("",false);
                
    } else {
                    
    this.writeError("Error at SQL Query: " ex.getMessage(), false);
                }
           
            }
            return 
    null;
        }
    EDIT!!! HOW DID I MISS THAT?! I completely ignored the default case ¬.¬ Sorry - Its 2am and I have had a rough day ;)
     
  27. Offline

    PatPeter

    Oh, I was going to ask you to restate your question, but I understand what you mean now. If you could, could you copy and paste the error when you use TOP? Without the error I can't help much.

    Also try this for limiting a query:

    Code:
    SELECT * FROM `table` LIMIT 0, 10
    Make sure to close your result sets properly or you'll lock your tables and I haven't released a fix (it will crash your server).

    So would it be two queries running threaded that you want, or a query and the main part of your plugin?

    I'm just glad it's working.
     
    gamemakertim and EarlyLegend like this.
  28. Offline

    Neodork

    Can you please un-private your Youtube explenation? I would be greatly indepted, wiki etc says its very good... So I want to watch it...
     
  29. Offline

    DrAgonmoray

    Query and the main part of my plugin. :D
     
  30. Offline

    PatPeter

    Firstly, it isn't my YouTube video, so I cannot. Secondly, you can ask me anything about installing the library or SQL in general and I'll answer to the best of my ability.

    I think you have to do that on your end of the code don't you? The library should work fine in a thread synchronous with the main thread of your plugin.
     
Thread Status:
Not open for further replies.

Share This Page