i'm trying to do the same thing, but can't get it to work as you've described.
i've commented out the connection values in my hibernate.cfg.xml and then run with the following:
Code:
Configuration config = new Configuration();
config.setProperty("connection.url", init.getDatabaseUrl());
config.setProperty("connection.username", init.getDatabaseUser());
config.setProperty("connection.password", init.getDatabasePass());
config.configure();
sessionFactory = config.buildSessionFactory();
when this is run i get the following warning, meaning the setProperty calls have had no effect
Code:
WARN org.hibernate.connection.UserSuppliedConnectionProvider - No connection properties specified - the user must supply JDBC connections
then when the connection is tested, it fails.
Code:
java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:54)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
any ideas?