Update existing database entry in java App-Collection of common programming errors

I am currently trying to make an update application (Java based) that the user can go through and view the existing database entries (MySQL) and edit them if need be… I was wondering how to get the information for a specific entry (ie 12-1589 which is an example of what the ID or primary key would be) and fill in the text boxes with all of the information from said entry…. I may just need to walk away from the computer for a bit because i may be over-thinking it, but I don’t know…

mainly i am unsure with the exact code that you would use to move to that entry and retrieve the data from just that entry…. I know how to step trough a database one entry at a time, but i would rather just jump to a specific row based off of an id number (such as above 12-1589) if at all possible….

I just tried this and i recieved an error…. The error was: “Unknown column ’12-1859′ in ‘where clause'”

con = DriverManager.getConnection(host, uName, uPass);
stmt = con.createStatement();       
String sql = "SELECT * FROM Load_Sheet WHERE Load_Number = 12-1859 limit 1";
rs = stmt.executeQuery(sql);
String BC = rs.getString("BC");

If anyone could give me a hand with that is going wrong i would appreciate it…

I just started getting another error along with the other one… it is : “illegal operation on empty result set”

Though the result sets are not empty so my guess is, is that i am missing a step somewhere….

  1. What you need is a simple WHERE statement if i understood correctly your question.

    SELECT * FROM table_name WHERE entry_col = "12-1589" LIMIT 1
    

    LIMIT 1 is only added so that the MySql query only returns a single row.