出于某种原因,我的hibernate应用程序的启动速度非常慢.(最多2分钟)我一直认为c3p0配置是完全错误的(相关问题),但研究日志显示,在建立与服务器的连接之后没有活动.此外,使用Hibernate的内置轮询功能也可以显示相同的结果.
这是日志的片段:
20:06:51,248 DEBUG BasicResourcePool:422 - decremented pending_acquires: 0
20:06:51,248 DEBUG BasicResourcePool:1644 - trace com.mchange.v2.resourcepool.BasicResourcePool@1acaf0ed [managed: 3, unused: 2, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@5f873eb2)
20:06:51,248 DEBUG BasicResourcePool:1644 - trace com.mchange.v2.resourcepool.BasicResourcePool@1acaf0ed [managed: 3, unused: 2, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@5f873eb2)
20:06:51,273 DEBUG JdbcServicesImpl:121 - Database ->
name : PostgreSQL
version : 9.1.6
major : 9
minor : 1
20:06:51,274 DEBUG JdbcServicesImpl:127 - Driver ->
name : PostgreSQL Native Driver
version : PostgreSQL 9.2 JDBC4 (build 1002)
major : 9
minor : …
Run Code Online (Sandbox Code Playgroud) 我正在使用dblink在数据库之间移动某些数据.一切都是保存和声音,但我想知道是否有更方便的方法来定义dblink查询结果的列定义列表.我可以这样做:
SELECT *
FROM dblink('dbname=remote', 'select * from test')
AS t1(id integer, data text);
Run Code Online (Sandbox Code Playgroud)
我正在与之交互的表在两个数据库(远程和本地)中具有相同的模式定义.我想的是:
SELECT *
FROM dblink('dbname=remote', 'select * from test')
AS t1 LIKE public.test;
Run Code Online (Sandbox Code Playgroud)
要么:
SELECT *
FROM dblink('dbname=remote', 'select * from test')
AS t1::public.test;
Run Code Online (Sandbox Code Playgroud)
列定义列表往往变得很长.有什么我可能忽略的吗?
编辑:
在我创建一个小函数作为解决方法之前,这对我来说是一个问题.
CREATE OR REPLACE FUNCTION dblink_star_func(_conn text, _schema_name text, _table_name text)
RETURNS text
LANGUAGE PLPGSQL
VOLATILE STRICT
AS $function$
DECLARE
_dblink_schema text;
_cols text;
_q text;
_func_name text := format('star_%s', $3);
_func text;
BEGIN
SELECT nspname INTO _dblink_schema
FROM pg_namespace …
Run Code Online (Sandbox Code Playgroud) 我无法理解为什么在我的Hibernate应用程序中初始化c3p0连接池需要2分钟.
这是在我的Hibernate.cfg.xml中:
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url"/>
<property name="connection.default_schema"/>
<property name="connection.username"/>
<property name="connection.password"/>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.min_size">3</property>
<property name="hibernate.c3p0.max_size">10</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="hibernate.c3p0."></property>
<property name="show_sql">true</property>
<property name="format_sql">false</property>
<property name="hbm2ddl.auto">create</property>
</session-factory>
</hibernate-configuration>
Run Code Online (Sandbox Code Playgroud)
在构建会话工厂时,在我的HibernateUtil文件中设置连接设置.
当我的测试中的第一个事务是openend时,池会初始化.连接和查询数据库之后工作得很好,它只会在下一行挂起一段时间才能启动.我把输出格式化了一下,因为我认为问题可能与这里提到的设置有关:
INFO: Initializing c3p0 pool...
com.mchange.v2.c3p0.PoolBackedDataSource@30670080 [
connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@ecfec4d0 [
acquireIncrement -> 1,
acquireRetryAttempts -> 30,
acquireRetryDelay -> 1000,
autoCommitOnClose -> false,
automaticTestTable -> null,
breakAfterAcquireFailure -> false,
checkoutTimeout -> 0,
connectionCustomizerClassName -> null,
connectionTesterClassName -> …
Run Code Online (Sandbox Code Playgroud) 我的基于Leaflet和AngularJS的地图未正确加载.我不知道发生了什么,但是地图图块并没有像它们应该的那样布局.
这是基本地图:
这是我的代码:
function setMapPosition(){
$scope.center = {
lat: 51.505,
lng: -0.09,
zoom: 8
};
$scope.defaults= {
scrollWheelZoom: false
};
$scope.tiles = 'openstreetmap';
}
Run Code Online (Sandbox Code Playgroud) hibernate ×2
java ×2
postgresql ×2
angularjs ×1
c3p0 ×1
dblink ×1
javascript ×1
jdbc ×1
leaflet ×1
sql ×1