I am having some trouble picking up the BindAddress property when
building my connection using JDBC in a standalone Java Swing
application. I'm guessing that I am not implementing it quite right
and am looking for a little guidance. Below is a snippet from my
hibernate config file and "no frills" session factory class.
Everything works great except for enforcing the bindaddress. As my
application must be able to function off-network, I cannot be bound to
the company IP. I'm using v1.3.155 on an XPsp3 tablet. Any help is
appreciated.
<hibernate-configuration>
<session-factory>
<property name="h2.bindAddress">127.0.0.1</property>
<property
name="connection.driver_class">org.h2.Driver</property>
<property name="connection.url">jdbc:h2:C:\journal\H2DB
\HNDLDATA;IFEXISTS=TRUE;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=5</property>
<property name="connection.username">xxxx</property>
<property name="password">xxxx</property>
<!-- <property
name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
-->
<property
name="hibernate.dialect">com.merck.handel.model.dms.service.CustomH2Dialect</
property>
<property name="defaultAutoCommit">true</property>
<!-- configuration pool via c3p0-->
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.idle_test_period">10</property> <!--
seconds --
>
<property name="c3p0.max_size">3</property>
<property name="c3p0.max_statements">10</property>
<property name="c3p0.min_size">1</property>
<property name="c3p0.timeout">60</property> <!-- seconds -->
<mapping resource="com/merck/handel/model/dms/domain/
UserSession.hbm.xml" />
<mapping resource="com/merck/handel/model/dms/domain/
Jsample.hbm.xml" />
( additional mappings removed )
</session-factory>
</hibernate-configuration>
---- session factoy class snippet ---
/**
* Configures and provides access to Hibernate sessions, tied to the
* current thread of execution. Follows the Thread Local Session
* pattern, see {@link http://hibernate.org/42.html }.
*/
public class HibernateSessionFactory {
/**
* Location of hibernate.cfg.xml file.
* Location should be on the classpath as Hibernate uses
* #resourceAsStream style lookup for its configuration file.
* The default classpath location of the hibernate config file is
* in the default package. Use #setConfigFile() to update
* the location of the configuration file for the current
session.
*/
private static String CONFIG_FILE_LOCATION = "classpath:/H2/
hibernate.cfg.xml";
private static final ThreadLocal<Session> threadLocal = new
ThreadLocal<Session>();
private static Configuration configuration = new
Configuration();
private static org.hibernate.SessionFactory sessionFactory;
private static String configFile = CONFIG_FILE_LOCATION;
static {
try {
configuration.configure(configFile);
sessionFactory = configuration.buildSessionFactory();
} catch (Exception e) {
System.err.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
private HibernateSessionFactory() {
}
/**
* Returns the ThreadLocal Session instance. Lazy initialize
* the <code>SessionFactory</code> if needed.
*
* @return Session
* @throws HibernateException
*/
public static Session getSession() throws HibernateException {
Session session = (Session) threadLocal.get();
if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
rebuildSessionFactory();
}
session = (sessionFactory != null) ?
sessionFactory.openSession() :
null;
threadLocal.set(session);
}
return session;
}
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.