【发布时间】:2015-06-20 21:10:50
【问题描述】:
我遇到了这个异常:
1266 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - Running hbm2ddl schema export
1266 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - exporting generated schema to database
1266 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - schema export unsuccessful
java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:54)
at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:263)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:219)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:370)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)
at com.vaannila.util.HibernateUtil.<clinit>(HibernateUtil.java:11)
at com.vaannila.student.Main.main(Main.java:14)
Exception in thread "main" 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:160)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:81)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473)
at com.vaannila.student.Main.main(Main.java:17)
请帮我解决这个问题。这是我的配置文件:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">sun.jdbc.odbc.JdbcOdbcDriver</property>
<property name="hibernate.connection.username"></property>
<property name="connection.password"></property>
<property name="connection.pool_size">1</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.conn.url">jdbc:odbc:demo</property>
【问题讨论】:
-
你能告诉我们你在哪里设置休眠并传递一个配置字符串吗?
-
我的休眠配置文件附在下面。
sun.jdbc.odbc.JdbcOdbcDriver 1 org.hibernate.dialect.SQLServerDialect jdbc:odbc:demo -
您是否尝试连接到其他数据库,例如hsqldb 还是 h2?
标签: java hibernate ms-access-2007 hibernate-mapping