[英]Cannot connect to database using hibernate with Microsoft Access
我有这个例外:
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>
检查您的休眠属性名称。
hibernate.conn.url
应该:
hibernate.connection.url
你的
连接密码
应该
休眠连接密码
其余的看起来不错,尽管重新检查了文档。 我看到您有一个空的密码字段和用户名属性。 您的odbc连接是否需要名称和密码?
如果您缺少登录凭据之类的其他信息,则修复连接字符串至少会给您一种新的错误类型。
这些xml配置非常麻烦!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.