问题描述
我希望我的应用程序在数据库中以特定名称注册.
I want my application be registered with particular name in DB.
我已经配置了 CAS 应用程序. CAS基于Spring框架.作为连接管理器,它使用c3p0.作为RDBMS,我使用PostgreSQL.
I have configured CAS application. CAS is based on Spring framework. As connection manager it uses c3p0. As RDBMS I use PostgreSQL.
在jdbcUrl中,我设置了以下内容:
In jdbcUrl I set the following:
jdbc:postgresql://localhost:5432/dbname?ApplicationName=CAS_TEST
在spring xml config中,我的dataSource看起来像:
in spring xml config my dataSource looks like:
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
p:driverClass="org.postgresql.Driver"
p:jdbcUrl="${my.db.url}"
p:user="${my.db.user}"
p:password="${my.db.password}" />
在Grails应用程序中使用jdbcUrl和应用程序名称的相同方法,一切都很好,但是Grails使用了另一个连接管理器,我想c3p0会削减url或其他内容.
The same approach with jdbcUrl and application name I use in Grails applications and everything is fine, but Grails uses another connection manager and I suppose c3p0 cuts url or something.
在这种情况下,有没有人有类似的经验或知道如何处理应用程序名称.
Does anyone have similar experience or know how to deal with application name in this case.
谢谢.
推荐答案
最后,我发现了问题所在.这不是c3p0问题.这是PostgreSQL驱动程序问题,我将其更改为最新版本,并且应用程序名称显示在数据库中.
Finally I've found where is a problem. It's not c3p0 issue. It was PostgreSQL driver issue, I've change it to the latest version and application name is appeared in the DB.
不起作用的驱动程序依赖性:
Not working driver dependency:
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>
工作驱动程序依赖性
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1209.jre7</version>
</dependency>
这篇关于使用c3p0的JDBC URL中的应用程序名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!