org.hibernate.exception.GenericJDBCException:无法提取ResultSet

时间:2019-01-13 07:20:31

标签: java hibernate

嗨,您能帮我解决这个问题吗?我在MySQL数据库中连接了此应用程序,每次运行此作业以从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

23:35:46.799 [DefaultQuartzScheduler_Worker-1]错误org.hibernate.engine.jdbc.spi.SqlExceptionHelper-无法读取来自服务器的响应。预期读取183个字节,读取75个字节,然后连接意外丢失。 javax.persistence.PersistenceException:org.hibernate.exception.GenericJDBCException:无法提取ResultSet         在org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:149)         在org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)         在org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1423)         在org.hibernate.query.Query.getResultList(Query.java:146)         在daos.ILCShiftEntriesDaoImpl.getListOfILCShiftEntriesWithLimitAndOffSet(ILCShiftEntriesDaoImpl.java:275)         在job.VarianceReportJobs.doILCWorkdayDBSync(VarianceReportJobs.java:400)         在工作时.VarianceReportJobs.execute(VarianceReportJobs.java:205)         在org.quartz.core.JobRunShell.run(JobRunShell.java:202)         在org.quartz.simpl.SimpleThreadPool $ WorkerThread.run(SimpleThreadPool.java:573) 原因:org.hibernate.exception.GenericJDBCException:无法提取ResultSet         在org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)         在org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)         在org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)         在org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:69)         在org.hibernate.loader.Loader.getResultSet(Loader.java:2168)         在org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1931)         在org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1893)         在org.hibernate.loader.Loader.doQuery(Loader.java:938)         在org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)         在org.hibernate.loader.Loader.doList(Loader.java:2692)         在org.hibernate.loader.Loader.doList(Loader.java:2675)         在org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2507)         在org.hibernate.loader.Loader.list(Loader.java:2502)         在org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502)         在org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:392)         在org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)         在org.hibernate.internal.StatelessSessionImpl.list(StatelessSessionImpl.java:464)         在org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445)         在org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414)         ...另外6个 原因:java.sql.SQLException:无法读取服务器的响应。预期读取183个字节,读取75个字节,然后连接意外丢失。         在com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)         在com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)         在com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)         在com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:974)         在com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1024)         在org.apache.commons.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:122)         在org.apache.commons.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:122)         在org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:60)         ...另外21个 javax.persistence.PersistenceException:org.hibernate.exception.GenericJDBCException:无法提取ResultSet         在org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:149)         在org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)         在org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1423)         在org.hibernate.query.Query.getResultList(Query.java:146)         在daos.ILCShiftEntriesDaoImpl.getListOfILCShiftEntriesWithLimitAndOffSet(ILCShiftEntriesDaoImpl.java:275)         在job.VarianceReportJobs.doILCWorkdayDBSync(VarianceReportJobs.java:400)         在工作时.VarianceReportJobs.execute(VarianceReportJobs.java:205)         在org.quartz.core.JobRunShell.run(JobRunShell.java:202)         在org.quartz.simpl.SimpleThreadPool $ WorkerThread.run(SimpleThreadPool.java:573) 原因:org.hibernate.exception.GenericJDBCException:无法提取ResultSet         在org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)         在org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)         在org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)         在org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:69)         在org.hibernate.loader.Loader.getResultSet(Loader.java:2168)         在org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1931)         在org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1893)         在org.hibernate.loader.Loader.doQuery(Loader.java:938)         在org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)         在org.hibernate.loader.Loader.doList(Loader.java:2692)         在org.hibernate.loader.Loader.doList(Loader.java:2675)         在org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2507)         在org.hibernate.loader.Loader.list(Loader.java:2502)         在org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502)         在org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:392)         在org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)         在org.hibernate.internal.StatelessSessionImpl.list(StatelessSessionImpl.java:464)         在org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445)         在org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414)         ...另外6个 原因:java.sql.SQLException:无法读取服务器的响应。预期读取183个字节,读取75个字节,然后连接意外丢失。         在com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)         在com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)         在com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)         在com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:974)         在com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1024)         在org.apache.commons.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:122)         在org.apache.commons.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:122)         在org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:60)         ...还有21

1 个答案:

答案 0 :(得分:0)

我在使用java.sql.SQLException时遇到了相同的错误:表太多; MySQL在一个联接中只能使用61个表

发生这种情况是因为关联了太多表 如果您不使用提取类型,则可能是由于关联而发生

例如-在我的情况下,我有150多张桌子 Book_Selling,退款等 在这种情况下,我创建了一个表来连接所有与付款有关的表。如果我从付款表中获取数据,它会连接所有其他表及其相关表,因此所有这些表的数量都超过了61个表。 在mysql默认情况下,您一次只能使用61个表创建联接查询

使用抓取类型为惰性,它将解决您的问题。