我正在使用Apache isis作为API,并使用SQL Server作为数据库。我注意到在数据库中执行查询的速度很慢。经过调查,我发现由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
#
#
persistor.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
答案 0 :(得分:1)
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