从SQL Server

时间:2018-05-18 07:54:23

标签: java sql-server jdbc

我有一个超过500K记录的表,当我尝试获取过滤结果集(~145K记录)时,我的closeConnection()方法崩溃了。在调试之后,事实证明语句对象一次获得1000条记录,并且连接在下一轮获取中间下降。 当我使用框架(雇主的框架)时,我无法更改超时设置,但我正在考虑立即获取整个大量的记录。仅供参考,性能在这里不是问题,因此如果需要更长时间并不重要。

在oracle中是否有类似ALL_ROWS提示的东西在SQL服务器中给出了相同的结果?或者其他一些解决方案?

这个查询:

SELECT MODEL.MODEL_TABLE_CODE VARIANT_ID, MODEL.DSC, MODEL.MAIN_MODEL_ID, MODEL.YEAR_FROM, MODEL_DN.SHOW_IN_PORTAL, MODEL.DISCONTINUE_DATE
FROM T_MODEL MODEL, T_MODEL_DN MODEL_DN
WHERE MODEL.MODEL_TABLE_CODE = MODEL_DN.ID
AND MODEL_DN.CHANNEL_TYPE_ID = @channel_type_id
AND MODEL.MAIN_VEHICLE_TYPE_ID = @main_vehicle_type_id
AND MODEL.UPDATE_DATE > @from_date

这是我在日志中得到的:

  

[18-05-18 06:49:03.661] ERROR默认任务-62 [] com.idit.framework.backend.interceptor.SessionBeanInterceptor -   org.hibernate.exception.GenericJDBCException:无法获取JDBC连接       在org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:102)~ [hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:129)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:47)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.engine.jdbc.internal.StatementPreparerImpl $ 5.doPrepare(StatementPreparerImpl.java:146)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       at org.hibernate.engine.jdbc.internal.StatementPreparerImpl $ StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:172)~ [hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:148)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.prepareQueryStatement(AbstractLoadPlanBasedLoader.java:241)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeQueryStatement(AbstractLoadPlanBasedLoader.java:185)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:121)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:86)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:167)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4019)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:508)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:478)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:219)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:278)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:121)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:89)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1222)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1105)~ [hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:646)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.type.ManyToOneType.assemble(ManyToOneType.java:266)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.type.TypeHelper.assemble(TypeHelper.java:99)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.cache.spi.entry.StandardCacheEntryImpl.assemble(StandardCacheEntryImpl.java:141)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.convertCacheEntryToEntity(DefaultLoadEventListener.java:754)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.processCachedEntry(DefaultLoadEventListener.java:625)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.java:602)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:462)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:219)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:278)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:121)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:89)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1222)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.internal.SessionImpl.access $ 1900(SessionImpl.java:204)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       at org.hibernate.internal.SessionImpl $ IdentifierLoadAccessImpl.doLoad(SessionImpl.java:2776)~ [hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       at org.hibernate.internal.SessionImpl $ IdentifierLoadAccessImpl.load(SessionImpl.java:2750)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]       在org.hibernate.internal.SessionImpl.get(SessionImpl.java:1058)〜[hibernate-core-5.2.5.Final.jar!/:5.2.5.Final]   块引用

由于

0 个答案:

没有答案