问题
I have a project that uses Hibernate 4.0.1 to interact with a derby database. That works fine. Here is a sample program that simply connects to the database and doesn't do anything:
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class DbTestMain {
public static void main(String... args){
Configuration derbyConfiguration = new Configuration().configure("hibernate-derby.cfg.xml");
SessionFactory derbySF = derbyConfiguration.buildSessionFactory();
Session derbySession = derbySF.openSession();
derbySession.close();
}
}
And here is the corresponding config:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
<property name="connection.url">jdbc:derby:TestDerbyDB;create=true</property>
<property name="connection.username"></property>
<property name="connection.password"></property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.DerbyDialect</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
</session-factory>
</hibernate-configuration>
And here is my classpath:

That works fine. But when I try to update to Hibernate 4.3.5, I get this error:
Exception in thread "main" org.hibernate.HibernateException: Unable to make JDBC Connection [jdbc:derby:C:\Users\Kevin\Desktop\TestDerbyDB;create=true]
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:77)
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:106)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
at DbTestMain.main(DbTestMain.java:9)
The only thing I've done is change my classpath to use Hibernate 4.3.5:

(For some reason, Hibernate 4.0.1 requires commons-collections, but Hibernate 4.3.5 does not.)
I'm not changing anything else, and the error message is frustratingly vague. Is there anything I'm doing wrong? Did something change that I need to update in my code?
My actual scenario is that I'm trying to pull code from an old (Hibernate 4.0.1) project and put it into a newer (Hibernate 4.3.5) project.
来源:https://stackoverflow.com/questions/34683790/hibernate-4-0-1-to-4-3-5-unable-to-make-jdbc-connection