Solved SQLibrary error TYPE_FORWARD_ONLY

Discussion in 'Plugin Development' started by ZephireNZ, Mar 23, 2013.

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

    ZephireNZ

    For anybody that has experience using SQLibrary, or that can still help.

    I've been unable to use result.last() because the ResultSet is apparently "TYPE_FORWARD_ONLY". I've seen on other threads for fixing this (not specifically for SQLibrary) that this can be stopped by using a "Statement" to run the query, along with ResultSet.TYPE_SCROLL_INSENSITIVE, but I've yet to find a way to use a Statement with the plugin. My code so far that's breaking:

    Code:java
    1. public void checkForPlayer(String player, long playTime) {
    2. try {
    3. plugin.getLogger().info("checkForPlayer Select");
    4. ResultSet result = SQLite.query("SELECT * FROM playTime WHERE player='" + player + "';");
    5. plugin.getLogger().info("checkForPlayer result.last");
    6. result.last();
    7. plugin.getLogger().info("Row: " + result.getRow());
    8. if(result.getRow() == 0) {
    9. plugin.getLogger().info("CheckForPlayer Insert");
    10. SQLite.query("INSERT INTO playTime(player, playTime) VALUES('" + player + "', '" + playTime + "');");
    11. }
    12. }catch (SQLException e) {
    13. plugin.getLogger().info("checkForPlayer Exception");
    14. plugin.getLogger().info(e.getMessage());
    15. }
    16. }


    Any help? If there's a better way of doing this, it'd be appreciated!

    Not to worry, I fixed this myself by using a COUNT(*) statement to get the number of rows. If anyone has the same error, I can post the way to fix it.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page