Recently in learning Java Connection Oracle database operation, inadvertently a small problem, wasted an afternoon and half a night to find this mistake, could have done more things, now will this error posted out, every time you see, will be encouraged!
1 ...........................2 3 Try {4String sql = "INSERT into T_test (user_id, user_name, password) VALUES (?,?,?)";5PST =conn.preparestatement (SQL);6 7 if(User.getuserid () = =NULL|| User.getusername () = =NULL|| User.getpassword () = =NULL)8 {9 Throw NewException ("Kong"));Ten } One APst.setstring (1, User.getuserid ()); -Pst.setstring (2, User.getusername ()); -Pst.setstring (3, User.getpassword ()); the - row = pst.executeupdate (sql); - } - Catch(Exception ex) { + -.................
Pst.executeupte ();
This statement is an execution statement, itself is a command, the command is to execute PST = conn.preparestatement (SQL), the database command is built, but in addition to add SQL is wrong, the previous statement to the placeholder assignment is all white.
Finally, Oracle gives the ORA-01008: Not all variables are bound to the error.
In the process of learning programming, there are some difficult to solve problems, and even some see have not seen the anomalies are commonplace, they can personally solve is the most valuable, this time this error occurs, microscopic speaking is his hand mistakenly habitual write on, but also from another level explained, Knowledge mastery of the rather weak, to go back and forth to see N times, also did not find the existence of this error, pay attention to it later!
Programming, careful never too much (record a bug in Java connection database)