私は、O/Rマッピングにhibernateを使用するJavaアプリケーションを持っています。また、hibernateと一緒に出荷されるc3p0接続プールも使用しています。 DBはOracleです。c3p0の最大接続数はLinuxでは動作しません
これは私のhibernate.cfg.xml
である:
<property name="hibernate.c3p0.min_size">3</property>
<property name="hibernate.c3p0.max_size">5</property>
<property name="hibernate.c3p0.max_statements">20</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.idleTestPeriod">120</property>
これは私がHibernateセッション入手方法です:
public class HibernateUtil {
private static Logger log = Logger.getLogger(HibernateUtil.class);
private static final SessionFactory sessionFactory;
private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure(CONFIG_FILE_LOCATION).buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
log.fatal("Initial SessionFactory creation failed." + ex.getMessage());
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
をしかし、私は、OracleでSELECT * FROM V$SESSION WHERE machine='xxx';
を実行したときに接続の数である、20に到達することができますmax_size
より大きい。
Linux環境では最大接続は機能しませんが、UnixおよびWindowsでは最大接続が機能します。 Linuxの設定を微調整する必要はありますか?
私はまた、以前に私がmax_size
に20を設定したように、アプリケーションのキャッシュがあると思われます。私はTomcat 5.5でアプリケーションを実行しています。しかし、Tomcatのアプリケーションキャッシュについてはわかりません。
別の情報:Linux 2.6.9-34.ELsmpを実行しています。 Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
ありがとうございます。
これはプロトコルの不一致です。バイナリ・ロード・リフター用のプロトコルに変換すると、C3P0は接続を使い果たすことなく完璧に相互運用できます。 – Kylar
Kylar、もっと親切に説明できますか?ありがとう。 –