If I dont set anything programmatically and just call Configuration configuration = new Configuration().configure(); and use the hibernate.properties (as below)
Even if you are setting the connection parameters (URL, username, passwords) programmatically you should make sure other conditions which would force the usage of JDBC connections at application startup are not present. I identified at least two:
Setting the hibernate.hbm2ddl.auto property to any other value than "none" forces a connection to the DB at startup; to validate, create or update the DB schema...
If you are using C3P0 properties in your hibernate.cfg.xml or persistence.xml, this also forces the pooling manager to try too acquire connections from the DB at startup
In all these cases, since you forced the connections to the DB without also configuring the connection parameters you will receive various error (like the one you faced)...
In order to fix these error either disable the property (hibernate.hbm2ddl) or set the other properties also programmatically (hibernate.c3p0.*)