Solved Get more then one result out of mysql

Discussion in 'Plugin Development' started by 0LUMIN4T0R, Nov 11, 2016.

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


    Hey Guys,
    i'm coding a little minigame at the moment and i want to save the locations, where an items spawn, in an database in mysql. But I get a NullPointerException in line 19.
    public static ArrayList getBronze(){
            Integer x = 0;
            Integer y = 0;
            Integer z = 0;
            ArrayList<Location> locs = new ArrayList<Location>();
                try {
    //next line is line 19
                    ResultSet rs = Main.mysql.query("SELECT * FROM Locations WHERE TYPE = '1'");
                    if(!( || (Integer.valueOf(rs.getInt("XWERT")) == null));
                    x = rs.getInt("XWERT");   
                    if(!( || (Integer.valueOf(rs.getInt("YWERT")) == null));
                    y = rs.getInt("YWERT");
                    if(!( || (Integer.valueOf(rs.getInt("ZWERT")) == null));
                    z = rs.getInt("ZWERT");
                    Location loc = new Location(Bukkit.getServer().getWorld("world-"), x, y, z);
                } catch (SQLException e) {
            return locs;
    I hope somebody can help me i'm very new to mysql in Java.
  2. Offline

    timtower Administrator Administrator Moderator

    @0LUMIN4T0R Every time that you call next then you go to the next record.
    So just the next in the while is enough.
  3. Offline


    On line 19, the only thing that could cause an NPE is that Main.mysql has not be instantiated yet.
  4. Offline


    Both together helped. thx:rolleyes:
Thread Status:
Not open for further replies.

Share This Page