Java.sql.SQLException: Invalid column index

Source: Internet
Author: User
Java.sql.SQLException: Invalid column index

"Invalid column index" is actually a low-level error for a few reasons:

1. The number of SQL strings and the number of variables provided are inconsistent:

For example: Jdbctemplate.update (SQL, new object[] {newstate,oldstate});

If there are 1 in SQL, object[] sent 2, it will be an error.

2. Incorrect writing of the number in SQL string

English? and Chinese? Sometimes it's hard to tell.

3. The number of SQL strings is enclosed in '.

For example: sql= "UPDATE abc SET abc.name= '?" WHERE abc.id= '? ';

get rid of it.

4, encounter this situation select*from user where info like%?%;

Although this is the SQL notation, it needs to be changed to Select*from user where info like in JDBC;

such as ps.setstring ("%" +value+ "%");

Java.sql.SQLException: Invalid column index

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.