此问题与此Question中的错误消息相关。但是我可以使用那里给出的答案来解决我的问题。
使用。本地启动HSQL服务器。
java-cp lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:MasterListMain --bname.0 MasterListMain
当我连接到服务器时,我得到:
[Server@4517d9a3]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@4517d9a3]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@4517d9a3]: Startup sequence initiated from main() method
[Server@4517d9a3]: Could not load properties from file
[Server@4517d9a3]: Using cli/default properties only
[Server@4517d9a3]: Initiating startup sequence...
[Server@4517d9a3]: Server socket opened successfully in 0 ms.
[Server@4517d9a3]: Database [index=0, id=0, db=file:MasterListMain, alias=mastelistmain] opened successfully in 391 ms.
[Server@4517d9a3]: Startup sequence completed in 391 ms.
[Server@4517d9a3]: 2016-08-30 18:55:54.144 HSQLDB server 2.3.4 is online on por 9001
[Server@4517d9a3]: To close normally, connect and execute SHUTDOWN SQL
[Server@4517d9a3]: From command line, use [Ctrl]+[C] to abort abruptly
org.hsqldb.HsqlException: Client driver version greater than '2.1.0.0' is requied. HSQLDB server version is '2.3.4'
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.server.ServerConnection.init(Unknown Source)
at org.hsqldb.server.ServerConnection.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
org.hsqldb.HsqlException: Client driver version greater than '2.1.0.0' is requied. HSQLDB server version is '2.3.4'
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.server.ServerConnection.init(Unknown Source)
at org.hsqldb.server.ServerConnection.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
这是意料之外的,因为我期待我的客户端也使用版本2.3.4。
gradle.build
读作:
apply plugin: 'eclipse'
apply plugin: 'application'
import groovy.sql.Sql
repositories {
mavenCentral()
}
mainClassName = "gui.MasterListMain"
configurations {
mail
junit
jdbc
sqllite
}
dependencies {
compile group: 'junit', name: 'junit', version: '4+'
// compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.8.11.2'
// hsqldb
compile 'org.hsqldb:hsqldb:2.3.4'
// JAR
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final'
// Hibernate
compile 'org.hibernate:hibernate-entitymanager:4.3.10.Final'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.commons:commons-collections4:4.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.0.2'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.0.2'
compile 'com.google.guava:guava:18.0'
compile 'commons-lang:commons-lang:2.6'
compile 'log4j:log4j:1.2.14'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.6.0'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.6.0'
compile group: 'com.googlecode.log4jdbc', name: 'log4jdbc', version: '1.2'
}
gradle dependencies
似乎也没问题
default - Configuration for default artifacts.
+--- junit:junit:4+ -> 4.12
| \--- org.hamcrest:hamcrest-core:1.3
+--- org.hsqldb:hsqldb:2.3.4
+--- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final
+--- org.hibernate:hibernate-entitymanager:4.3.10.Final
| +--- org.jboss.logging:jboss-logging:3.1.3.GA
| +--- org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1
| +--- org.hibernate:hibernate-core:4.3.10.Final
| | +--- org.jboss.logging:jboss-logging:3.1.3.GA
| | +--- org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1
| | +--- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.0.Final
| | +--- dom4j:dom4j:1.6.1
| | | \--- xml-apis:xml-apis:1.0.b2
| | +--- org.hibernate.common:hibernate-commons-annotations:4.0.5.Final
| | | +--- org.jboss.logging:jboss-logging:3.1.3.GA
| | | \--- org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1
| | +--- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final
| | +--- org.javassist:javassist:3.18.1-GA
| | +--- antlr:antlr:2.7.7
| | \--- org.jboss:jandex:1.1.0.Final
| +--- dom4j:dom4j:1.6.1 (*)
| +--- org.hibernate.common:hibernate-commons-annotations:4.0.5.Final (*)
| +--- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final
| +--- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.0.Final
| \--- org.javassist:javassist:3.18.1-GA
+--- org.apache.commons:commons-lang3:3.3.2
+--- commons-io:commons-io:2.4
+--- org.apache.commons:commons-collections4:4.0
+--- org.apache.logging.log4j:log4j-api:2.0.2
+--- org.apache.logging.log4j:log4j-core:2.0.2
| \--- org.apache.logging.log4j:log4j-api:2.0.2
+--- com.google.guava:guava:18.0
+--- commons-lang:commons-lang:2.6
+--- log4j:log4j:1.2.14
+--- org.slf4j:slf4j-api:1.6.0
+--- org.slf4j:slf4j-log4j12:1.6.0
| +--- org.slf4j:slf4j-api:1.6.0
| \--- log4j:log4j:1.2.14
\--- com.googlecode.log4jdbc:log4jdbc:1.2
\--- org.slf4j:slf4j-api:1.6.0
在我的客户端日志中,我找到了:
WARN 2016-08-30 19:24:02,314 501 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl [main] HHH000402: Using Hibernate built-in connection pool (not for production use!)
INFO 2016-08-30 19:24:02,314 501 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl [main] HHH000401: using driver [org.hsqldb.jdbcDriver] at URL [jdbc:hsqldb:hsql://localhost/MasterListMain]
INFO 2016-08-30 19:24:02,314 501 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl [main] HHH000046: Connection properties: {user=SA}
INFO 2016-08-30 19:24:02,314 501 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl [main] HHH000006: Autocommit mode: false
INFO 2016-08-30 19:24:02,314 501 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl [main] HHH000115: Hibernate connection pool size: 20 (min=1)
DEBUG 2016-08-30 19:24:02,314 501 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl [main] Initializing Connection pool with 1 Connections
DEBUG 2016-08-30 19:24:03,439 1626 org.hibernate.jpa.HibernatePersistenceProvider [main] Unable to build entity manager factory
org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:132)
at
[...]
Caused by: java.sql.SQLTransientConnectionException: java.net.ConnectException: Connection refused: connect
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source)
任何想法,在哪里定义正确的版本?
谢谢,BerndGit
答案 0 :(得分:0)
确定。找到根本原因:修改gradle.build后,在eclipse中没有自动更新hsql版本。
问题已经结束。