resultset 对象获取行字段数据时报:java.sql.SQLException: Column 'id' not found.
resultset 对象获取行字段数据时报:java.sql.SQLException: Column 'id' not found.
代码:
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("不ok???????????????");
try {
while(resultset.next()){
int id =resultset.getInt("id");
int categoryId = 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 =new News();
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");的时候报错
原因:与下面查询sql中的查询结果字段要匹配,要有这个结果才行,因为resultset取的是符合sql条件的结果集中每个字段,如果你select都不查这个字段,那它当然报找不到。
所以改为:
搞定~~~~~~~~~~~
resultset 对象获取行字段数据时报:java.sql.SQLException: Column 'id' not found.的更多相关文章
- hibernate 出现Caused by: java.sql.SQLException: Column 'id' not found.异常
用hibernate进行映射查询时,出现Caused by: java.sql.SQLException: Column 'id' not found 异常,检查数据库表及映射都有id且已经正确映射, ...
- Spring boot启动时报 java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long错误
Spring boot启动时报 java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be ...
- ibatis 更改resultmap后 java.sql.SQLException: Column 'del_status' not found.
当在resultmap中增加字段后,查询语句也必须增加相应字段,否则会报错, java.sql.SQLException: Column 'del_status' not found. 因为查询结果与 ...
- java.sql.SQLException:Column count doesn't match value count at row 1
1.错误描述 java.sql.SQLException:Column count doesn't match value count at row 1 2.错误原因 在插入数据时,插入的字段 ...
- java.sql.SQLException:Column count doesn't match value count at row 1
1.错误描写叙述 java.sql.SQLException:Column count doesn't match value count at row 1 2.错误原因 在插入数据时,插入的 ...
- 启动Spring boot报错:nested exception is java.sql.SQLException: Field 'id' doesn't have a default value
先看具体日志: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with n ...
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
1.错误描述 org.hibernate.exception.GenericJDBCException: error executing work at org.hibernate.exception ...
- java.sql.SQLException:Column Index out of range,0<1
1.错误描述 java.sql.SQLException:Column Index out of range,0<1 2.错误原因 try { Class.forName("com.m ...
- Hibernate报错:Caused by: java.sql.SQLException: Field 'ID' doesn't have a default value
问题一: 报错如下: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assig ...
随机推荐
- 理解IEnumerator+IEnumerable这种接口思想
前言 本文不想过多篇幅来介绍IEnumerator和IEnumerable这两个接口的具体说明,只是把它作一个例子作引言而已,本文将根据自己的理解来描述微软为何要这样设计这种关联风格的接口.这种风格的 ...
- 转一篇关于Unity的PlayMaker
这篇文章转自http://va.lent.in/should-you-use-playmaker-in-production/ 此文作者大概深受其苦,吐槽了playmaker的多个蛋疼的地方,这其实说 ...
- matlab 功率谱分析
matlab 功率谱分析 1.直接法:直接法又称周期图法,它是把随机序列x(n)的N个观测数据视为一能量有限的序列,直接计算x(n)的离散傅立叶变换,得X(k),然后再取其幅值的平方,并除以N,作为序 ...
- jaccard similarity coefficient 相似度计算
Jaccard index From Wikipedia, the free encyclopedia The Jaccard index, also known as the Jaccard ...
- 用户 'IIS APPPOOL\***' 登录失败
用户 'IIS APPPOOL\DefaultAppPool' 登录失败. 我在windows8中安装了iis之后添加了我做的网站打开之后提示用户 'IIS APPPOOL\DefaultAppPoo ...
- js简易函数性能测试器
如果你不想用浏览器的js性能测试工具,可以用下面这个简单的函数测试一下(1毫秒一下的就测不出来了) function testFn(fn,param){ var start = new Date(). ...
- 【BZOJ 1911】【APIO 2010】特别行动队
http://www.lydsy.com/JudgeOnline/problem.php?id=1911 夏令营里斜率优化的例题,我调了一晚上,真是弱啊. 先推公式吧($sum_i$表示$x_1 \d ...
- 【BZOJ 2152】聪聪可可 点分治
对于一棵树,fdrt找到重心,然后分治每个子树. 在一棵以重心为根的树上,符合条件的链是: 1.过重心(根) 2.不过重心 对于1我们只需dfs出距离重心(根)的距离然后统计再减去有重叠的边 对于2我 ...
- C++中的重载隐藏覆盖&&JAVA中的重载覆盖&&多态
class 类继承默认是private, struct 默认继承是public C++中的隐藏: 只要派生类中出现和基类一样的函数名,基类中的函数就会被派生类中的函数给隐藏(如果派生类和基类中的函数名 ...
- bzoj1012
Description 现在请求你维护一个数列,要求提供以下两种操作:1. 查询操作.语法:Q L 功能:查询当前数列中末尾L 个数中的最大的数,并输出这个数的值.限制:L不超过当前数列的长度.2. ...