- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 NetBeans 来制作我的 Java 项目。在我的数据库表或 DTO 中,它们都有一个名为“paymentDate ”的列。我不明白为什么它会发送此错误。奇怪的是,当我将“PAYMENTDATE”更改为“DATE”时,系统会向我发送另一个错误:严重:没有名为“CLIENTORDERID ”的列。
客户订单代码:
package dbase;
import dto.ClientDTO;
import dto.clientOrderDTO;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
public class ClientOrder {
private static final String PERSON_ORDER = "SELECT clientName, orderName, paymentDate AS Date "
+ "FROM Client JOIN clientOrder ON Client.id = clientOrder.clientId "
+ "WHERE Client.id = ? ";
public ArrayList<clientOrderDTO> findCurrentClientOrderForClient(ClientDTO client) throws SQLException{
ArrayList<clientOrderDTO> list = new ArrayList<>();
Connection con = DB_Manager.getConnection();
try{
PreparedStatement stmt = con.prepareStatement(PERSON_ORDER);
stmt.setInt(1, client.getId());
ResultSet rs = stmt.executeQuery();
while(rs.next()){
Calendar paymentDate = Calendar.getInstance();
paymentDate.setTime(rs.getDate("PAYMENTDATE"));
clientOrderDTO order = new clientOrderDTO(
rs.getInt("CLIENTORDERID"),
client,
rs.getString("ORDERNAME"),
paymentDate
);
list.add(order);
}
con.close();
}
catch (NullPointerException npe)
{
System.err.println("No connection available");
}
catch (SQLException sqle)
{
System.err.println(sqle.getMessage());
}
return list;
}
}
创建表
CREATE TABLE Client(
id integer not null primary key generated always as identity (start with 1, increment by 1),
clientName varchar(20) not null,
username varchar(10) not null unique,
pwd varchar(50) not null
);
CREATE TABLE clientOrder(
id integer not null primary key generated always as identity (start with 1, increment by 1),
clientId integer not null,
orderName varchar(20) not null,
paymentDate Date not null,
constraint client_FK foreign key(clientId) references Client(id)
);
DTO:
package dto;
import java.io.Serializable;
public class ClientDTO implements Serializable
{
private final int id;
private final String name;
private final String username;
private final String password;
public ClientDTO(int id, String name, String username, String password){
this.id = id;
this.name = name;
this.username = username;
this.password = password;
}
public int getId(){
return id;
}
public String getName(){
return name;
}
public String getUsername(){
return username;
}
public boolean passwordMatches(String pwd){
return password.equals(pwd);
}
}
package dto;
import java.io.Serializable;
import java.util.Calendar;
import javax.inject.Named;
@Named(value = "clientOrder")
public class clientOrderDTO implements Serializable{
private final int id;
private final ClientDTO client;
private final String orderName;
private Calendar paymentDate;
public clientOrderDTO(int id, ClientDTO client, String orderName,Calendar paymentDate){
this.id = id;
this.client = client;
this.orderName = orderName;
this.paymentDate = paymentDate;
}
public int getId(){
return id;
}
public ClientDTO getClient(){
return client;
}
public String getOrderName(){
return orderName;
}
public Calendar getPaymentDate(){
return paymentDate;
}
public void setPatmentDate(Calendar paymentDate){
this.paymentDate = paymentDate;
}
}
最佳答案
在您的查询中,您已将 paymentDate
列别名为 Date
:
paymentDate AS Date
因此您应该使用的列名称是Date
。
此外,SELECT
列表中也没有名称或别名 CLIENTORDERID
的列。如果您想使用列的值,则该列必须出现在 SELECT
列表中,以便查询返回它。
关于java - 严重: There is no column named: "PAYMENTDATE ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59695611/
目前我正在调试我们的应用程序一个看似随机的错误。我将尝试提供尽可能多的细节。基本上过了一会儿,我们服务器上的应用程序的一个应用程序池停止了。我必须启动它,或者有时,重新启动 Coldfusion 或更
在寻找其他东西时,完全出于巧合,我偶然发现了一些关于案例类继承是多么邪恶的评论。有一个叫做 ProductN 的东西,可怜虫和国王, Sprite 和巫师,以及案例类继承如何丢失某种非常理想的属性。那
我正在从服务器下载媒体内容,并且应用程序在一定时间后崩溃,并给出以下错误: 收到内存压力通知(严重) 当我在 didReceiveMemoryWarning 函数中收到警告时删除了所有对象,但没有运气
为什么我会遇到这个错误 我开发了 Jax-Rs Web 服务 Jersey、Maven、Hibernate 和 Spring。如何解决该错误? Aug 03, 2015 2:23:17 PM com.
我是 Perl 新手。我收到此错误: CRITICAL : "file does not exist" 当我尝试运行脚本来通过 Nagios 监视 httpd 错误日志时。 #!/bin/sh # C
我最近一直在努力在 Kivy 中创建一个填充的 Circle,当窗口的大小调整为不同的宽度或高度时,它仍然是一个圆。我在这里看了问题: Centering an object in Kivy 但是当我
我想用实验编程语言实现的主要目的之一是:发生错误(语法,名称,类型等)时,无论程序有多严重或破坏性如何,都可以保持程序运行。 我知道这可能非常糟糕,但是我只想要一些不会在每个错误中都消失的东西-,我发
我使用 NetBeans 来制作我的 Java 项目。在我的数据库表或 DTO 中,它们都有一个名为“paymentDate ”的列。我不明白为什么它会发送此错误。奇怪的是,当我将“PAYMENTDA
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
我正在使用Grails 1.3.4,后者使用了Hibernate,并且针对Oracle 11g数据库。我的应用程序启动失败,出现以下错误: 2010-11-04 09:45:34,671 INFO
自从我执行了 pip install google-api-python-client 后,我的 Gunicorn worker 在超时后停止了。 Django==1.5.3 unicorn ==
这个问题已经有答案了: 已关闭10 年前。 Possible Duplicate: Connecting to SQLite Database Fails 我是 Java 初学者 当我想从 SQLit
在我的实体类中,我有以下内容,调用一个返回 sys_refcursor 的 oracle 函数 @Entity @javax.persistence.NamedNativeQuery(
我们在生产环境中遇到了这个问题,但无法追踪。技术:JSP/Servlets,Jetty 服务器版本:jetty-distribution-8.1.15, 以下是异常(exception)情况,我们在
我有一个基于网络的应用程序,每三秒我连接到一个数据库并从 GPS 设备查询数据。 不幸的是,当应用程序工作超过几个小时时我无缘无故地得到了异常:“严重:没有找到适合jdbc的驱动程序......”。应
之前我的 tomcat 服务器运行良好。 但突然出现以下错误。 请帮忙解决这个问题 SEVERE: A child container failed during start java.util.co
请不要标记为重复,因为其他解决方案还没有帮助! 我在尝试运行本教程时在浏览器中收到 404: http://www.vogella.com/articles/REST/article.html 实际上
使用 Spring Tool Suite 3.6.3,我将以下内容添加到 Maven Web 项目的 POM.XML 中。 com.MyCompany.sei MyCompany-a
我在 tomcat 上部署了 RESTful Web 服务'该 Web 服务在同一域场景的客户端/服务器中工作正常'但我需要使 Web 服务可从跨域使用'为此我使用了 CORS 过滤器. 我在 myP
我第一次尝试使用 ServletContextListener 在每次部署应用程序时执行特定函数。为此,我采用了一个简单的 java 类文件并在其上实现了 ServletContextListener
我是一名优秀的程序员,十分优秀!