java - ResultSet exception - before start of result set -


I ResultSet is having trouble receiving data from object here is my code:

  string sql = "SELECT type FROM node WHERE nid =?"; Submit Prepared Placement = conn.prepareStatement (sql); Int meetNID = integer Parasent (node.get (BoutField.field_meet_nid)); Prep.setInt (1, meetNID); Results Result = prep.executeQuery (); Result.beforeFirst (); String found type = result .getString (1); If (! FoundType.equals ( "meet")) (new illegal orientation exception throwing (string. Format ( "node% d" must meet "but% s, meetNID, foundType));}  

error:

  Thread exceptions "main" java.sql.SQLException: Com.mysql before starting the set results Comkmysqlkjdbc. in. Com.mysql.jdbc.SQLError.createSQLException at jdbc (SQLError.java:981) at com.mysql.jdbc.SQLError.createSQLException (SQLError.java:986) SQLError.createSQLException (SQLError.java:1072) com.mysql. on jdbc.ResultSetImpl.checkRowPos (ResultSetImpl.java:841) com.mysql.jdbc.ResultSetImpl.getStringInternal (ResultSetImpl.java teterm66) .QLError.createSQLException (SQLError.ja on com.mysql Va: 926) at jdbc.ResultSetImpl.getString (ResultSetImpl.java:5576) at nd.cumf3.nodeImport.Main.main (main.java38) at nth.cumf3.nodeImport.Validator.validate (validator.java:43) I am  

what I wrong here?

in fact, You are first in the position of the cursor and then request the data. You need to move the cursor to the first line.

  result.next (); String found type = result .getString (1);  

It is common to do this in a statement or loop.

  if (result.next ()) {foundType = result.getString (1); }  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -