Help MySQL Error

Discussion in 'Plugin Development' started by IcyRelic, Apr 15, 2013.

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

    IcyRelic

    Ok im trying to get a integer from a row in the database here is how im doing it

    Code:
                    rs = st.executeQuery("SELECT temptime FROM bans WHERE username = '"+p.getName()+"' ORDER BY id LIMIT 0, 1");
                    int tempend = Integer.parseInt(rs.getString(1));
    but it returns an error saying

    19:04:17 [INFO] Before start of result set

    Help?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  2. Offline

    Terradominik

    we have to see the full code and the database to help you right. The error occurs, because the pointer is at the wrong position (before the first element)
     
  3. Offline

    Spikes

    Code:java
    1. ResultSet rs = null;
    2. int result = 0;
    3. rs = st.executeQuery("SELECT temptime FROM bans WHERE username = '"+p.getName()+"' ORDER BY id LIMIT 0, 1");
    4. try {
    5. if (rs != null && rs.next()) {
    6. result = rs.getInt("name");
    7. }
    8. } catch (SQLException e) {
    9. e.printStackTrace();
    10. }
     
    Terradominik likes this.
  4. Offline

    IcyRelic

    I'll try that
     
  5. Offline

    stuntguy3000

    while rs.next
    {
    rs.getint(pieface);
    }
     
Thread Status:
Not open for further replies.

Share This Page