Pulling a variable from a MySQL Database

Discussion in 'Plugin Development' started by AppleBabies, Dec 12, 2015.

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

    AppleBabies

    Hello. I have a plugin installed called MoneySQL. It is is a variable called <money>. I am wondering how I can pull this and use it in my plugin. What I am trying to do is take that variable and put it in an item lore. (Code examples below) Thanks in advance!

    NOTE: I do have all of Huskehhh's dependencies installed.

    MySQLManager.java
    Code:
    package me.applebabies.ah;
    
    import java.sql.SQLException;
    import java.sql.Statement;
    
    public class MySQLManager {
        private final Main main;
       
        private MySQL db;
       
        public MySQLManager(Main m) {
            this.main = m;
        }
       
        public void setupDB() throws ClassNotFoundException, SQLException {    
            //Redacted info:
            this.db = new MySQL("r", "r", "r", "r", "r");
            this.db.openConnection();
            Statement statement = this.db.getConnection().createStatement();
           
        }
    }
    
    Where I want the variable to be put:
    Code:
    private ItemStack bagelStack(String name){
                ItemStack waterBucket = new ItemStack(Material.BREAD);
                  ItemMeta im = waterBucket.getItemMeta();
                  im.setDisplayName(name);
                  im.setLore(Arrays.asList(ChatColor.RED + "" + ChatColor.UNDERLINE + "<money>"));
                  waterBucket.setItemMeta(im);
                return waterBucket;
               
            }
     
  2. Offline

    mythbusterma

    @AppleBabies

    Why are you using SQL? Also, why aren't you doing it yourself? There's literally no point in using someone else's code for this.
     
  3. Offline

    AppleBabies

    @mythbusterma I use BungeeCord to store a common value between servers. There is a value in that plugin's table called money, which is stored under mysql. I am doing this myself, I just need to read the value...I simply used the MySQL API provided by Huskehhh...
     
  4. Offline

    mythbusterma

    @AppleBabies

    It's not an API. It's literally a single file that you could easily write yourself to have a better purpose built application. An API is what the MySQL JDBC connector exposes. It's something that actually takes significant effort to write.

    Regardless, what even is your question? That file Husky gave has methods for creating statements (albeit incorrectly), did you read the page it was on?
     
  5. Offline

    AppleBabies

    @mythbusterma What is the point of writing your own file when there's an already provided file that lots of plugin creators use?

    I did those see methods. I understand how to get ONE value, but I'm asking how to get a value from a stored person's UUID...look, here's my table, attached below...

    If you are going to criticize me for how I prefer doing things, don't even bother helping me. Unfollow and close this thread. Because I was simply asking for HELP, not criticism...
     

    Attached Files:

  6. Offline

    mythbusterma

    @AppleBabies

    To make it more integrated, streamlined, and less awful.

    So your question is about how to formulate an SQL statement? http://www.w3schools.com/tags/tag_select.asp

    My criticism has been nothing but constructive, and has been directed at improving your skills and plugin quality.
     
  7. Locked, Bungeecord forces servers into offline mode which is not supported here.
     
Thread Status:
Not open for further replies.

Share This Page