Buggy code:
@ WebServlet ( name = "getImages" , urlPatterns = { "//getImages" } ) public class getImages extends HttpServlet { private String dbURL = "" ; private String dbUser = "" ; private String dbPass = "" ; private String host = System . getenv ( "OPENSHIFT_MYSQL_DB_HOST" ) ; private String port = System . getenv ( "OPENSHIFT_MYSQL_DB_PORT" ) ; protected void processRequest ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { dbURL = ( ( ( ( "jdbc:mysql:////" + ( host ) ) + ":" ) + ( port ) ) + "//" ) + "barter" ; dbUser = System . getenv ( "OPENSHIFT_MYSQL_DB_USERNAME" ) ; dbPass = System . getenv ( "OPENSHIFT_MYSQL_DB_PASSWORD" ) ; Connection conn = null ; String message = null ; String title = null ; String title2 = null ; String title3 = null ; String title4 = null ; String desc = null ; String desc2 = null ; String desc3 = null ; String desc4 = null ; try { DriverManager . registerDriver ( new Driver ( ) ) ; conn = DriverManager . getConnection ( dbURL , dbUser , dbPass ) ; Statement st = conn . createStatement ( ) ; ResultSet rs = st . executeQuery ( "SELECT<seq2seq4repair_space>title<seq2seq4repair_space>FROM<seq2seq4repair_space>item" ) ; rs . first ( ) ; title = rs . getString ( "title" ) ; rs . next ( ) ; title2 = rs . getString ( "title" ) ; rs . next ( ) ; title3 = rs . getString ( "title" ) ; rs . next ( ) ; title4 = rs . getString ( "title" ) ; ResultSet rsd = st . executeQuery ( "SELECT<seq2seq4repair_space>item_desc<seq2seq4repair_space>FROM<seq2seq4repair_space>item" ) ; rsd . first ( ) ; Blob blob = rsd . getBlob ( "item_desc" ) ; byte [ ] bdata = blob . getBytes ( 1 , ( ( int ) ( blob . length ( ) ) ) ) ; desc = new String ( bdata ) ; rsd . next ( ) ; Blob blob2 = rsd . getBlob ( "item_desc" ) ; byte [ ] bdata2 = blob2 . getBytes ( 1 , ( ( int ) ( blob . length ( ) ) ) ) ; desc2 = new String ( bdata2 ) ; rsd . next ( ) ; Blob blob3 = rsd . getBlob ( "item_desc" ) ; byte [ ] bdata3 = blob3 . getBytes ( 1 , ( ( int ) ( blob . length ( ) ) ) ) ; desc3 = new String ( bdata3 ) ; <START_BUG> rsd . next ( ) ; <END_BUG> Blob blob4 = rsd . getBlob ( "item_desc" ) ; byte [ ] bdata4 = blob4 . getBytes ( 1 , ( ( int ) ( blob . length ( ) ) ) ) ; desc4 = new String ( bdata4 ) ; } catch ( SQLException ex ) { message = "ERROR:<seq2seq4repair_space>" + ( ex . getMessage ( ) ) ; ex . printStackTrace ( ) ; } finally { if ( conn != null ) { try { conn . close ( ) ; } catch ( SQLException ex ) { ex . printStackTrace ( ) ; } } request . setAttribute ( "title" , title ) ; request . setAttribute ( "title2" , title2 ) ; request . setAttribute ( "title3" , title3 ) ; request . setAttribute ( "title4" , title4 ) ; request . setAttribute ( "desc" , desc ) ; request . setAttribute ( "desc2" , desc2 ) ; request . setAttribute ( "desc3" , desc3 ) ; request . setAttribute ( "desc4" , desc4 ) ; getServletContext ( ) . getRequestDispatcher ( "//welcome.jsp" ) . forward ( request , response ) ; } } @ Override protected void doGet ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { } @ Override protected void doPost ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { } @ Override public String getServletInfo ( ) { } }

Fix:
rsd . last ( ) ;