Hi. I have a swing application that uses hibernate to talk to a Derby database. I've had this setup for years without an issue. I've been using the following cgf file:
Code:
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
<property name="hibernate.connection.url">jdbc:derby:C:\Program Files\myAPP\client\data\</property>
<property name="hibernate.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property>
<mapping resource="myapp.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Here's my problem. We now allow the user to install our app anywhere -
meaning that the path to the database will not be know at compile time - so I can't specify it in the cfg file and tuck the file into our jar.
I reread the hibernate guide and came up with this code:
Code:
Configuration cfg = new Configuration()
.addResource( "myApp.cfg.xml" ).
.setProperty( "hibernate.dialect", "org.hibernate.dialect.DerbyDialect" )
.setProperty( "hibernate.connection.datasource", datasourceBuilder.toString() )
.setProperty( "hibernate.connection.driver_class", "org.apache.derby.jdbc.EmbeddedDriver" );
sessionFactory = cfg.buildSessionFactory();
i get the following error:
Code:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
i've tried to research this, but I'm coming up blank. I understand that the <session-factory> element in the XML can have a name, but i didn't see anything in the
http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/session-configuration.html#configuration-programmatic that discusses naming the session factory... should i have to do this? i'm not using jndi in my swing app.
thanks in advance for your help!!