wicket - 使用 apache isis 打开到 sql 的连接没有关闭
问题描述
我将 Apache isis 用于 API,并将 SQL 服务器用作 DB。我注意到在 DB 中执行查询的速度很慢。在调查中,我发现 Apache ISIS 打开的连接尚未关闭并且处于睡眠状态。这导致了许多打开但处于休眠状态的连接,从而降低了性能。我阅读了 apache isis 文档,发现连接池正在由 apache isis 处理。是否需要添加一个属性,以便在会话关闭后关闭连接。我被这个问题困住了,任何帮助将不胜感激。提前致谢。干杯!
编辑:Persistor_datanucleus.properties
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# configuration file for the JDO/DataNucleus objectstore
#
#
# hook to perform additional initialization when JDO class metadata is loaded
# default implementation will attempt to run 'create schema' for the specified schema.
#
# this implementation is installed by default:
#isis.persistor.datanucleus.classMetadataLoadedListener=org.apache.isis.objectstore.jdo.datanucleus.CreateSchemaObjectFromClassMetadata
# whether to persist the event data as a "clob" or as a "zipped" byte[]
# default is "zipped"
#isis.persistor.datanucleus.PublishingService.serializedForm=zipped
#####################################################################
#
# DataNucleus' configuration
#
# The 'isis.persistor.datanucleus.impl' prefix is stripped off,
# remainder is passed through to DataNucleus
#
#####################################################################
isis.persistor.datanucleus.impl.datanucleus.schema.autoCreateAll=true
isis.persistor.datanucleus.impl.datanucleus.schema.validateTables=true
isis.persistor.datanucleus.impl.datanucleus.schema.validateConstraints=true
#
# Require explicit persistence (since entities are Comparable and using ObjectContracts#compareTo).
# see http://www.datanucleus.org/products/accessplatform_3_0/jdo/transaction_types.html
#
isis.persistor.datanucleus.impl.datanucleus.persistenceByReachabilityAtCommit=false
#
# How column names are identified
# (http://www.datanucleus.org/products/datanucleus/jdo/orm/datastore_identifiers.html)
#
isis.persistor.datanucleus.impl.datanucleus.identifier.case=MixedCase
#
# L2 cache
# off except if explicitly marked as cacheable
# http://www.datanucleus.org/products/datanucleus/jdo/cache.html
#
isis.persistor.datanucleus.impl.datanucleus.cache.level2.type=none
isis.persistor.datanucleus.impl.datanucleus.cache.level2.mode=ENABLE_SELECTIVE
#
# uncomment to use JNDI rather than direct JDBC
#
#isis.persistor.datanucleus.impl.datanucleus.ConnectionFactoryName=java:comp/env/jdbc/quickstart
#
# uncomment to use JTA resource
#
#isis.persistor.datanucleus.impl.datanucleus.ConnectionFactory2Name=java:comp/env/jdbc/quickstart-nontx
#isis.persistor.datanucleus.impl.javax.jdo.option.TransactionType=JTA
#
#
# JDBC connection details
# ... are in persistor.properties
#
#
持久化器.properties
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#################################################################################
#
# Persistor
#
#################################################################################
# generally speaking this should not be enabled
isis.persistor.disableConcurrencyChecking=false
----Few lines that have been commented out----
isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL=jdbc:sqlserver://localhost:1433;database=myDB
isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName=sa
isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword=password
解决方案
Apache Isis使用DataNucleus提供的连接池,可以通过设置DN配置属性进行配置,见http://www.datanucleus.org/products/accessplatform_4_1/persistence_properties.html
要在persistor.properties 中指定这些,请在它们前面加上“isis.persistor.datanucleus.impl”。- 这些是直接通过的。
也可以将 Apache Isis 配置为使用 JNDI 提供的数据源,请参阅 http://isis.apache.org/guides/ugodn/ugodn.html#_ugodn_configuring_using-jndi-data-source
推荐阅读
- python - 在 python 上生成特定图的问题
- node.js - 安装 puppeteer 会引发错误,并显示“无法安装脚本 'node install.js'”
- python-3.x - 从 Django DeleteView 返回到 Django ListView 分页列表中的右侧页面
- java - 导入与当前类同名的类
- python - 使用打印功能的缩进逻辑
- python - 使用 Selenium-Python 检查页面中是否存在文本的最佳方法
- algorithm - 测试一组中的哪些圆相交
- ml - 在 Poly/ML 编程中计算没有重复的元素列表
- c# - 如何在c#中解码一些编码文本
- asp.net-core - Conditional rendering in asp.net core razor, without evaluating expression