ResultSet object gets row field data times: Java.sql.SQLException:Column ' id ' not found.

Source: Internet
Author: User

ResultSet object gets row field data times: Java.sql.SQLException:Column ' id ' not found.

Code:

String sql= "Select D.content,c.name as CategoryName from News_detail d,news_category C WHERE d.categoryid=c.id"; Object[] Params={}; System.out.println ( This. ExecuteQuery (sql, params)); ResultSet ResultSet= This. ExecuteQuery (sql, params); System.out.println ("Not OK???????????????"); Try {             while(Resultset.next ()) {intID =resultset.getint ("id"); intCategoryId = Resultset.getint ("CategoryId"); String CategoryName= Resultset.getstring ("CategoryName"); String title= Resultset.getstring ("title"); String Summary= Resultset.getstring ("Summary"); String content= resultset.getstring ("Content"); String author= Resultset.getstring ("Author"); Timestamp CreateDate= Resultset.gettimestamp ("CreateDate"); News News=NewNews ();                News.setid (ID);                News.setcategoryid (CATEGORYID);                News.settitle (title);                News.setsummary (summary);                News.setcontent (content);                News.setauthor (author);                News.setcategoryname (CategoryName);                                News.setcreatedate (CreateDate); Newslist.add (news);
int ID =resultset.getint ("id");  When the error
Cause: This is the result of matching the query result fields in the query SQL below, because resultset takes each field in the result set that meets the SQL criteria, and if you select does not check this field, it certainly does not find it.

So instead:

Fix ~~~~~~~~~~~.

ResultSet object gets row field data times: Java.sql.SQLException:Column ' id ' not found.

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.