MySQL vs Default Saving

Discussion in 'Plugin Development' started by Eggspurt, Jul 15, 2015.

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

    Eggspurt

    Will it really make or break my server? MySQL just seems confusing by reading the tutorials that bukkit users have generously donated but I can't seem to understand it but I mean I will learn to love MySQL if it makes that much of a difference.
     
  2. Offline

    Gater12

    @Eggspurt
    What are you trying to achieve/looking for?
     
  3. Offline

    SuperOriginal

    There are probably a billion discussions about MySQL vs other data storage types
     
  4. Offline

    mythbusterma

    @Eggspurt

    If you need to store millions of records, use the information on a webserver, or use the information on another server, use MySQL. Otherwise use configuration files.

    Other than the aforementioned, it's a waste of time, as programming for an SQL database (properly) in Bukkit is actually rather difficult. Any time I see someone on here ask about it, they have it extremely poorly done with statics in stateful Objects and synchronous queries. It makes me cry because they feel like "hurr durr mastaaa progmmurr" because they can use someone else's awful "library" (and I use that phrase in the very loosest sense of that word) and write terrible SQL queries with it.

    /rant
     
  5. @Eggspurt Let's say you are making an economy plugin, which keeps track of the top 100 most rich persons. You want those to have listed and updated automatically on your website, then I would go for MySQL storage, as you can easily access the database with PHP, even if the database is on a completely other server. If so, the database needs external access enabled.
    You could for example also connect their I game name with their website account and let them retrieve everything about their user via website.
    And as I LOVE to connect things with my website, I would definitely go for it. :) With flatfile you could do that under circumstances too, for example if the website and gameserver would be on the same root and you would smartly put the server in a good path, accessible from the website. But I don't know if that would be good because of security reasons and if it wouldn't have a problem when accessing the same file from 2 different sources.
    But if you do want to make a public plugin, which does store any data useful to the end-user, I would use both, so people can choose on their own if they need MySQL or if they're good with flatfile.
     
  6. Offline

    Eggspurt

    So what's the point if I am not doing it right?

    I currently use YML for Storage Saving, how would I use FlatFile?
     
  7. @Eggspurt if I'm not wrong, that is flatfile. I don't know, nobody is perfect. XD
     
  8. Offline

    Eggspurt

    I've also seen FILENAME.flatfile before so thats why I was confused :p
     
  9. @Eggspurt Oh, I have no idea haha, until now I always called .yml files flatfile. :D
     
  10. Offline

    mythbusterma

    @Eggspurt

    We can show you how to do it right, if you're willing to learn. That being said, it isn't easy and it takes a lot more time to program.

    If you don't need to, it's just easier to use a flatfile.

    @Lionhard

    In general, flatfile refers to schema-less non-database oriented storage, things like YAML, so that's an appropriate use of the phrase.
     
    Lionhard likes this.
  11. Offline

    Eggspurt

    If you're willing to teach me I would be willing to learn!
     
  12. Offline

    mythbusterma

    @Eggspurt

    Well, first off, don't touch any of the so called "tutorials" or (again, using this word loosely) "libraries" posted here in the Bukkit forums, most of them are drivel.

    You're probably going to want a class that you use to connect to the database, and have it keep track of a Connection object. Make it connect when the server starts.

    Start with that, and we can work from there, if you need help making the connection: http://dev.mysql.com/doc/connector-j/en/connector-j-usagenotes-connect-drivermanager.html
     
  13. Offline

    Eggspurt

    Would I just use this code?

    Code:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    
    Connection conn = null;
    ...
    try {
    conn =
    DriverManager.getConnection("jdbc:mysql://localhost/test?" +
    "user=minty&password=greatsqldb");
    
    // Do something with the Connection
    
    ...
    } catch (SQLException ex) {
    // handle any errors
    System.out.println("SQLException: " + ex.getMessage());
    System.out.println("SQLState: " + ex.getSQLState());
    System.out.println("VendorError: " + ex.getErrorCode());
    }
    Replace the Localhost user and password info?
     
  14. Offline

    mythbusterma

    @Eggspurt

    You're probably going to want to make a class with that, but that's the general idea.
     
Thread Status:
Not open for further replies.

Share This Page