【问题标题】:The connections opened to sql using apache isis are not closed使用 apache isis 打开到 sql 的连接没有关闭
【发布时间】:2018-12-19 17:26:14
【问题描述】:

我使用 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
#
#

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

【问题讨论】:

  • 你的意思是他们在一个连接池中?和?定义你正在使用的连接池
  • 我不确定 ISIS 框架内部使用的是哪个连接池
  • @BillyFrost 你能告诉我你想查看哪个文件吗,因为我的工作区中有很多与 isis 相关的配置文件
  • @BillyFrost 添加了似乎与数据库配置相关的文件。
  • 因此它根据 DataNucleus 文档使用内部 DBCP2 连接池,如果您关闭 PM 并关闭 PMF,它将释放连接

标签: wicket jdo datanucleus isis


【解决方案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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多