Programming, careful never too much (record a bug in Java connection database)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.