我需要用java访问SQLite数据库。我得到这个错误:用java访问SQLite数据库
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.dialect.SQLiteDialect] as strategy [org.hibernate.dialect.Dialect]
每当我想创建我的sessionFactory bean。
数据库属性:
db.driver.class=org.sqlite.JDBC
db.server.url=jdbc:sqlite:"G:\\Ausbildung\\username\\Database\\informations.db"
db.username=
db.password=
db.hibernate.dialect=org.hibernate.dialect.SQLiteDialect
db.hibernate.schema=DATA
db.hibernate.hbm2ddl.auto=update
bean声明在XML文件:
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
lazy-init="true">
<property name="driverClassName">
<value>${db.driver.class}</value>
</property>
<property name="url">
<value>${db.server.url}</value>
</property>
<property name="username">
<value>${db.username}</value>
</property>
<property name="password">
<value>${db.password}</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"
lazy-init="true">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>com.mainfirst.bloomberg.invoice.report.model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${db.hibernate.dialect}</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.default_schema">${db.hibernate.schema}</prop>
<prop key="hibernate.hbm2ddl.auto">${db.hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.connection.CharSet">utf8</prop>
<prop key="hibernate.connection.characterEncoding">utf8</prop>
<prop key="hibernate.connection.useUnicode">true</prop>
</props>
</property>
</bean>
我无法找到我所犯的错误。这个构造与Apache Derby一起工作。我只改变了hibernate.dialect和driver.class以及server.url。
如果我删除“”在db.server.url我得到的错误
Caused by: java.lang.AbstractMethodError: org.sqlite.Conn.isValid(I)Z
在此先感谢
通过采用更新版本的jdbc驱动程序修复了java.lang.AbstractMethodError。现在只有方言错误存在 – XtremeBaumer