title: SQLException: Before start of result set
body: <p>I've checked this issue in other posts and it said that to point on the first line in the table I need to perform "result.next()" .
  But still I get this problem, I checked the input of the function, it's ok and matches the info in the database.
  it doesn't perform the "while" loop, like the content of the table is empty...
  I'm using GWT so the debugging is painful ! </p>
  
  <p>The table : picId(primary_key), book, fromChapter, toChapter ....(the important ones)</p>
  
  <p>content: book = 1 , chapter = 6.
  and the database contains such a row.
  I hope i'm not missing something stupid over here as usual ! :)</p>
  
  <pre><code>public List&lt;PicAsset&gt; getPicture(int book, int chapter) throws Exception
  
    {
  
      System.out.print("getPicture ok " + book +"," + chapter);
      Connection conn = null;
      PreparedStatement pstmt = null;
      ResultSet result = null;
      List&lt;PicAsset&gt; relevantAssets = new ArrayList&lt;PicAsset&gt;();
      PicAsset relAsset;
  
  
      try {
          conn = getConnection();
          pstmt = conn.prepareStatement("SELECT * FROM picasset WHERE book = ? AND fromChapter = ?");
  
          //System.out.print("connection" + conn);
          pstmt.setInt(1, book);
          pstmt.setInt(2, chapter);
         // pstmt.setInt(3, chapter);
         // pstmt.setInt(4, chapter);
          result = pstmt.executeQuery();
  
  
          while (result.next()) {
  
              System.out.print(result.next());
              relAsset = new PicAsset(result.getInt("picId"),result.getInt("book"), result.getInt("fromChapter"), result.getInt("toChapter"),result.getInt("fromVerse"),result.getInt("toVerse"),result.getString("creator"),result.getString("discription"),result.getString("source"),result.getString("title"),result.getString("duration"),result.getString("url"));
              relevantAssets.add(relAsset);
  
          }
      }
  
          catch (SQLException sqle) 
          {
              sqle.printStackTrace();
          } 
          finally
          {
              // Cleanup
              result.close();
              pstmt.close();
              conn.close();
          }
  
      return relevantAssets;
  
  
      }
  }
  </code></pre>
  
  <p>Stack trace:</p>
  
  <pre><code>getPicture ok 1,6connectioncom.mysql.jdbc.Connection@18e476fajava.sql.SQLException: Before start of result set
      at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:700)
      at com.mysql.jdbc.ResultSet.getNativeString(ResultSet.java:3747)
      at com.mysql.jdbc.ResultSet.getStringInternal(ResultSet.java:4979)
      at com.mysql.jdbc.ResultSet.getString(ResultSet.java:4810)
      at com.biblereader.server.MySQLConnection.getPicture(MySQLConnection.java:151)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
      at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:265)
      at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:305)
      at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
      at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
      at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:68)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
      at org.eclipse.jetty.server.Server.handle(Server.java:370)
      at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
      at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:960)
      at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1021)
      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
      at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
      at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>