MysqlInvalidcolumnname and Thoughts on java program upgrade

Source: Internet
Author: User
For Yuanyuan, upgrading the original program is definitely a pain point, but more painful: except for one projcet, there is nothing else, even database fields are not described, not to mention design documents, database design documents, and Requirement documents. Recently, the big boss asked to upgrade a project six years ago, not only to upgrade the program

For Yuanyuan, upgrading the original program is definitely a pain point, but more painful: except for one projcet, there is nothing else, even database fields are not described, not to mention design documents, database design documents, and Requirement documents. Recently, the big boss asked to upgrade a project six years ago, not only to upgrade the program

For Yuanyuan, upgrading the original program is definitely a pain point, but more painful: except for one projcet, there is nothing else, even database fields are not described, not to mention design documents, database design documents, and Requirement documents.

Recently, the big boss asked me to upgrade a project six years ago, not only to upgrade the program, but also to change the interface, but also to migrate the SQL server database to mysql. But when I got the project, it's really big. Because there is nothing except the project itself, and the project developer has left the company early, there is no document, and there is no field description for each table, I can only guess the meaning of each field based on the sixth sense of the programmer ......


If you don't talk nonsense, you can directly talk about the problem. When you modify a query, the following error occurs: java. SQL. SQLException: Invalid column name. At first glance, how can I use a project that can run well before without any changes? The statement is as follows:

SELECT distinct s. id AS id, s. name AS name, s. url AS url, s. siteMap as siteMap, s. isFlag as isFlag, s. stat AS stat, t. id as tmpl_id, t. description as tmDescription FROM bbs_site1 s left join bbs_tmpl1 t ON s. tmpl_id = t. id where 1 = 1


Since the edges and corners, gu ba has completely driven out of the land of China. Well, what do you mean? Don't you have to live or make money, it's not difficult, but it's hard to find out what I want. Why is this statement an error?


Ben yuanbaisi cannot solve this problem. He tried to use the index to obtain the string. No, he used the SQL resultset to obtain the string. It was not OK. I was so angry,


Fortunately, my brother finally found the cause because rowset (inherited resultset) is used at the underlying layer of the program. I am not satisfied with the id of the red part, it does not take the value based on the alias behind the as, and then the value based on the id, it is really unknown, but after finding the problem, the solution will come. The first uses id (rs. getInt ("id"), and the second id uses the index value (rs. getInt (index), so that everything is OK. I really don't know that there is such a big pitfall. I am taught, so it is recorded here.


After the change, I thought that I really thought that the previous ideas and methods were inappropriate. I could just give myself some comments:

1. During program design, the meaning of a field must be described. Even if it is not described, a clear description should be provided in the document.

2. Each field conforms to the common and easy-to-use principle. You can see what it means when you look at the field. For example, name, person has name, and item has name. If you locate the name, it is not good, it should be well defined: Will per_name and pro_name be much better?

3. There are no instructions in this document, which makes codes changed very dizzy.

4. note: This is also a headache. In this project, he did not give a comment. I have kakaka, a function that writes dozens of lines, and it is still a line break, brother is really angry, or really angry.

5. scalability is not taken into account in many cases. This is a common feature especially when programs are upgraded or new features are added. It is worth thinking about.

6. Public, general methods, classes, and functions must be proposed. Never write them once, which is too troublesome.


The above six points are a small suggestion proposed by Ben. They are indeed worth thinking about ,,,,,,


I know all this, and once again, it is nothing more than to pay attention to it. But what I do is just my own way.

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.