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 ...
随机推荐
- Qt 5.2 Creator 和 vs2012 QT 插件的安装
在QT官网下载QT http://qt-project.org/downloads 我下的是64位版本Qt 5.2.1 for Windows 64-bit vs2012插件是 Visual Stu ...
- Theano2.1.3-基础知识之更多的例子
来自:http://deeplearning.net/software/theano/tutorial/examples.html More Examples 现在,是时候开始系统的熟悉theano的 ...
- Adblock Plus for firefox
关于 Adblock Plus for firefox(以下简称 ABP)的一些笔记. 安装好 ABP,将如下代码保存为 html 文件,然后在 firefox 中打开: <p id=" ...
- How to build windows azure PowerShell Source Code
Download any version source code of Windows Azure Powershell from https://github.com/Azure/azure-sdk ...
- Vmware player 12
免费版的虚拟机Vmware,体积小.运行快速... 官方下载界面 下载地址: http://yunpan.cn/cm5smywVvqS8V 访问密码 35ac 官方下载:点击下载
- 【jQuery EasyUI系列】使用属性介绍
1.ValidateBox The validatebox is designed to validate the form input fields.If users enter invalid v ...
- 17-tail 简明笔记
显示文件的最后一部分(尾部) tail [options] [file-list] 参数 file-list是tail要显示的文件的路径名列表.当制定多个文件时,tail在显示每个文件的内容之前先显示 ...
- Vue-loader 开启压缩后的一些坑
在使用vue-loader 配合webpack 对.vue文件进行加载的时候,如果开启了代码压缩会出来下面几种问题,做个记录. 丢失td结束标记,导致页面的布局错乱 input的属性type为text ...
- Linux 安装mysql+apache+php
安装mysql 1. yum install mysql mysql-server 2. 修改mysql密码 >use mysql >update user set passwor ...
- 选项卡js
趁着公司不忙,抓紧充充电,开始可能会写的不好,但是每写一个都是一点进步,哈哈,加油 用js实现选项卡切换 1.获取元素 2.初始状态 3.通过循环清空元素状态 4.点击操作以及对应的内容切换 5.自定 ...