Org.postgresql.util.PSQLException: Field index exceeds license range: 3, Number of columns: 2.

Source: Internet
Author: User
Tags postgresql

Org.postgresql.util.PSQLException: Field index exceeds license range: 3, Number of columns: 2.

Today, after writing the SQL query, the background has been error display the above information. Looking at the error for no reason at all, we re-examined the SQL and found that I added quotation marks to the outside of one of the receiving parameters while others did not add.

If the suspicion is caused by this, delete the quotation mark and execute again, there is no recurrence of the problem; look at the rest of the information, say yes. #{parentid} transposition ${parentid}, so it was tested in the case of quotation marks, the # will not be reported to the error. So I looked for a little bit about the difference between # and $ in sql:

1. # When the incoming data is treated as a string, a double quotation mark is added to the automatically passed data such as: SELECT * from User where parentid = #{parentid} When the value of ParentID is 100

SQL resolves to select * from User where parentid = "100"

2. $ The incoming data is displayed directly in the SQL statement such as: SELECT * from User where parentid = ${parentid} When the value of ParentID is 100

SQL resolves to select * from User where parentid = 100

The main difference is that: why do I need to use $ instead of # when I add quotes to my program?

Other than that:

1. #方式能够很大程度上防止sql注入, and $ cannot prevent SQL injection;

2. $ is typically used for incoming database objects, such as incoming table names;

3. MyBatis sort when using the order by dynamic parameter when using $ instead of #;

In short, you can use # when you don't need $ this is good;

Org.postgresql.util.PSQLException: Field index exceeds license range: 3, Number of columns: 2.

Related Article

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.