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.