I have just done the same, but I don't create a new datasource outside the container. When you run code outside the container you have to use another hibernate.cfg.xml where you specify driver_class, url, username and password.
My hibernate.cfg.xml (for use in Tomcat) looks like this: <hibernate-configuration> <session-factory> <property name="connection.datasource">java:comp/env/jdbc/hibernate</property> <property name="show_sql">false</property> <property name="dialect">net.sf.hibernate.dialect.SybaseDialect</property> <mapping resource="Person.hbm.xml"/> </session-factory> </hibernate-configuration> And my hibernate.standalone.cfg.xml looks like this: <hibernate-configuration> <session-factory> <property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property> <property name="connection.url">jdbc:jtds:sqlserver://156.116.2.208/perjadatabase</property> <property name="connection.username">username</property> <property name="connection.password">pass</property> <property name="show_sql">false</property> <property name="dialect">net.sf.hibernate.dialect.SybaseDialect</property> <mapping resource="Person.hbm.xml"/> </session-factory> </hibernate-configuration> In the JUnit class you have to specify that it should use hibernate.standalone.cfg.xml: Configuration config = new Configuration(); try { config.configure(new File("hibernate.standalone.cfg.xml")); SessionFactory sessFact = config.buildSessionFactory(); Session session = sessFact.openSession(); ... fre, 12.12.2003 kl. 05.22 skrev hanasaki: > Hibernate has been setup to use the data source provided by Tomcat. > There are some JUnit tests that need to be run on code segments/classes > that are not running inside the container. How can a Datasource and > java:comp/env/jdbc be create and setup for the application outside of > the container? > > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys admin. > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > _______________________________________________ > hibernate-devel mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/hibernate-devel -- Per Thomas Jahr ------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel