嗨,你能帮我解决这个问题吗。我在MySQL DB中连接了这个应用程序,每次运行这个作业从DB中取数据时,我总是会得到这个异常(参见添加了Java类、DAO和方法以及apache DBCP2配置的全栈跟踪)。
POJO class
@Entity
public class ILCShiftEntries implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column
private int month;
@Column
private int year;
@Column
private int date;
@Column
private String groupId;
@Column
private String countryCode;
@Column
private String employeeSerialNumber;
@Column
private String employeeLastName;
@Column
private String employeeDeptNumber;
@Column
private String accountId;
@Column
private String workItemId;
@Column
private String workItemDesc;
@Column
private String activityCode;
@Column
private String activityDesc;
@Column
private String billingCode;
@Column
private String weekEndingDate;
@Column
private String overtimeInd;
@Column
private String satHoursExpended;
@Column
private String sunHoursExpended;
@Column
private String monHoursExpended;
@Column
private String tuesdayHoursExpended;
@Column
private String wedHoursExpended;
@Column
private String thuHoursExpended;
@Column
private String friHoursExpended;
@Column
private String totalHoursExpended;
@Column
private String createdTimeStamp;
@Column
private String sumiterSerialNumber;
@Column
private String lbrRptInd;
@Column
private String employeeEffectiveDate;
@Column
private String labStatus;
@Transient
private String serialNumber;
@Transient
private String workDayManager;
@Transient
private String workDayManagerSerialNumber;
@Column
private String sourceApplicationId;
@Column
private String siteLocation;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int getDate() {
return date;
}
public void setDate(int date) {
this.date = date;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getCountryCode() {
return countryCode;
}
public void setCountryCode(String countryCode) {
this.countryCode = countryCode;
}
public String getEmployeeSerialNumber() {
return employeeSerialNumber;
}
public void setEmployeeSerialNumber(String employeeSerialNumber) {
this.employeeSerialNumber = employeeSerialNumber;
}
public String getEmployeeLastName() {
return employeeLastName;
}
public void setEmployeeLastName(String employeeLastName) {
this.employeeLastName = employeeLastName;
}
public String getEmployeeDeptNumber() {
return employeeDeptNumber;
}
public void setEmployeeDeptNumber(String employeeDeptNumber) {
this.employeeDeptNumber = employeeDeptNumber;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getWorkItemId() {
return workItemId;
}
public void setWorkItemId(String workItemId) {
this.workItemId = workItemId;
}
public String getWorkItemDesc() {
return workItemDesc;
}
public void setWorkItemDesc(String workItemDesc) {
this.workItemDesc = workItemDesc;
}
public String getActivityCode() {
return activityCode;
}
public void setActivityCode(String activityCode) {
this.activityCode = activityCode;
}
public String getActivityDesc() {
return activityDesc;
}
public void setActivityDesc(String activityDesc) {
this.activityDesc = activityDesc;
}
public String getBillingCode() {
return billingCode;
}
public void setBillingCode(String billingCode) {
this.billingCode = billingCode;
}
public String getWeekEndingDate() {
return weekEndingDate;
}
public void setWeekEndingDate(String weekEndingDate) {
this.weekEndingDate = weekEndingDate;
}
public String getOvertimeInd() {
return overtimeInd;
}
public void setOvertimeInd(String overtimeInd) {
this.overtimeInd = overtimeInd;
}
public String getSatHoursExpended() {
if( NumberUtil.toDouble( satHoursExpended ) > 0 ){
return satHoursExpended;
}
return "0";
}
public void setSatHoursExpended(String satHoursExpended) {
this.satHoursExpended = satHoursExpended;
}
public String getSunHoursExpended() {
if( NumberUtil.toDouble( sunHoursExpended ) > 0 ){
return sunHoursExpended;
}
return "0";
}
public void setSunHoursExpended(String sunHoursExpended) {
this.sunHoursExpended = sunHoursExpended;
}
public String getMonHoursExpended() {
if( NumberUtil.toDouble( monHoursExpended ) > 0 ){
return monHoursExpended;
}
return "0";
}
public void setMonHoursExpended(String monHoursExpended) {
this.monHoursExpended = monHoursExpended;
}
public String getTuesdayHoursExpended() {
if( NumberUtil.toDouble( tuesdayHoursExpended ) > 0 ){
return tuesdayHoursExpended;
}
return "0";
}
public void setTuesdayHoursExpended(String tuesdayHoursExpended) {
this.tuesdayHoursExpended = tuesdayHoursExpended;
}
public String getWedHoursExpended() {
if( NumberUtil.toDouble( wedHoursExpended ) > 0 ){
return wedHoursExpended;
}
return "0";
}
public void setWedHoursExpended(String wedHoursExpended) {
this.wedHoursExpended = wedHoursExpended;
}
public String getThuHoursExpended() {
if( NumberUtil.toDouble( thuHoursExpended ) > 0 ){
return thuHoursExpended;
}
return "0";
}
public void setThuHoursExpended(String thuHoursExpended) {
this.thuHoursExpended = thuHoursExpended;
}
public String getFriHoursExpended() {
if( NumberUtil.toDouble( friHoursExpended ) > 0 ){
return friHoursExpended;
}
return "0";
}
public void setFriHoursExpended(String friHoursExpended) {
this.friHoursExpended = friHoursExpended;
}
public String getTotalHoursExpended() {
return totalHoursExpended;
}
public void setTotalHoursExpended(String totalHoursExpended) {
this.totalHoursExpended = totalHoursExpended;
}
public String getCreatedTimeStamp() {
return createdTimeStamp;
}
public void setCreatedTimeStamp(String createdTimeStamp) {
this.createdTimeStamp = createdTimeStamp;
}
public String getSumiterSerialNumber() {
return sumiterSerialNumber;
}
public void setSumiterSerialNumber(String sumiterSerialNumber) {
this.sumiterSerialNumber = sumiterSerialNumber;
}
public String getLbrRptInd() {
return lbrRptInd;
}
public void setLbrRptInd(String lbrRptInd) {
this.lbrRptInd = lbrRptInd;
}
public String getEmployeeEffectiveDate() {
return employeeEffectiveDate;
}
public void setEmployeeEffectiveDate(String employeeEffectiveDate) {
this.employeeEffectiveDate = employeeEffectiveDate;
}
public String getLabStatus() {
return labStatus;
}
public void setLabStatus(String labStatus) {
this.labStatus = labStatus;
}
public String getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
public String getWorkDayManager() {
return workDayManager;
}
public void setWorkDayManager(String workDayManager) {
this.workDayManager = workDayManager;
}
public String getWorkDayManagerSerialNumber() {
return workDayManagerSerialNumber;
}
public void setWorkDayManagerSerialNumber(String workDayManagerSerialNumber) {
this.workDayManagerSerialNumber = workDayManagerSerialNumber;
}
public String getSourceApplicationId() {
return sourceApplicationId;
}
public void setSourceApplicationId(String sourceApplicationId) {
this.sourceApplicationId = sourceApplicationId;
}
public String getSiteLocation() {
return siteLocation;
}
public void setSiteLocation(String siteLocation) {
this.siteLocation = siteLocation;
}
}
Dao Class
public class ILCShiftEntriesDaoImpl implements ILCShiftEntriesDao{
@Override
public List< ILCShiftEntries > getListOfILCShiftEntriesWithLimitAndOffSet( StatelessSession statelessSession, int limitNumber, int offsetNumber ) {
List<ILCShiftEntries > listOfILCShiftEntries = null;
Query query = statelessSession.createQuery("from ILCShiftEntries order by id desc");
query.setFirstResult( offsetNumber );
query.setMaxResults( limitNumber );
List list = query.getResultList();
if( Utilities.isListNotEmpty( list ) ){
listOfILCShiftEntries = ( List<ILCShiftEntries > )list;
}
return listOfILCShiftEntries;
}
}
apache DBCP2 config
database.dbcp.maxTotal=-1
database.dbcp.maxIdle=8
database.dbcp.minIdle=0
database.dbcp.initialSize=20
database.dbcp.maxWaitMillis=23904
database.dbcp.testWhileIdle=true
database.dbcp.maxOpenPreparedStatements=-1
database.dbcp.validationQuery=SELECT 1
database.dbcp.softMinEvictableIdleTimeMillis=300000
database.dbcp.timeBetweenEvictionRunsMillis=300000
null
我在java.sql.SQLException中得到了相同的错误:表太多;MySQL在一个联接中只能使用61个表
这是因为关联了太多的表。如果不使用fetch类型,则可能是因为关系
例如,在我的例子中,我有超过150个表Book_Selling、recharge等。我创建一个表来连接所有关于付款的表。在这种情况下,如果我从付款表获得数据,它连接所有其他表以及它们相关的表,因此所有表的计数超过61个表。在mysql默认值中,一次只能使用61个表创建联接查询
使用fetch类型为lazy,那么它将解决您的问题。
问题内容: 我正在使用hibernate3.6.7进行映射。我将连接部分设置为静态。我需要服务程序永远运行,另一个服务将调用该服务的某些方法来查询数据库。当我让该服务运行时,第一天工作良好,但是第二天我调用它时,它给出了: 似乎连接已关闭。有人可以给我一些建议吗? 非常感谢你:) 问题答案: 听起来好像数据库已关闭连接或某个网络设备已终止套接字。您可以通过多种方法来解决此问题: 您可以经常在连接上
问题内容: 安慰: 问题: 当我从类执行函数时,就会发生这种情况。这是怎么回事 问题答案: 如下更改查询: 否则如下: 中相应的比较 ,其中 子句是具有文字,而不是另一列。因此,必须在第一种情况下用引号引起来,或者在第二种情况下使用绑定变量。
我无法获取结果,create查询正在执行,但之后将其转换为list无法工作。请帮我解决这个问题。为什么它没有被转换成列表我无法获取结果,创建查询正在被执行,但之后将它转换成列表不起作用。请帮我解决这个问题。为什么它没有被转换成列表 表脚本 bean类 控制器方法是: 错误日志 null AnswerEntity类
目前,我在为springboot项目获取mysql数据时遇到了一个问题: 编辑:Application.Properties 我能够使/test/welcome映射工作,因此我相信我对服务和控制器的实现是正确的。所以我想知道我是不是在访问存储库中的数据库时犯了一个错误,还是应该使用JpaRepository而不是CrudRepository并使用显式查询? 编辑堆栈跟踪:org.springfra
我已经将支持JAR和jdbc驱动程序添加到我的项目中,但我仍然得到了低于例外情况 getting找不到resultset异常错误执行load命令:getting sqlgrammerexception 我的配置文件
这是我的POJO类,名为Student,我为它创建了一个表来更新标记。 这是我的主要班级 当我尝试执行该操作时,它显示了另一个错误,错误是“student0_”。“verson”:无效标识符