我想通過Gavin King的Java Persistence與Hibernate學習Hibernate。無法從底層數據庫獲取連接! - HSQL DB
我剛剛下載從這個位置http://downloads.jboss.org/hibernate/caveatemptor/jpwh-gettingstarted-070401.zip
書中給出的例子,我開始我的HSQL DB使用螞蟻startdb和數據庫成功啓動。
當試圖運行目標的SchemaExport我收到以下錯誤..
SchemaExport工具:[hibernatetool] 執行的Hibernate工具與 標準配置[hibernatetool] 1.任務:就是hbm2ddl(生成數據庫模式)[hibernatetool] 18:07:56,555 INFO Environment:500 - Hibernate 3.2.0.cr5 [hibernatetool] 18:07:56,555 INFO Environment:533 - hibernate.properties not fo und [hibernatetool] 18: 07:56,555信息 環境:667 - 字節碼提供呃 名稱:CG LIB [hibernatetool] 18:07:56571信息環境:584 - 使用JDK 1.4的java.sql.Time郵票 處理[hibernatetool] 18:07:56617 信息配置:1384 - 從文件中配置 :H ibernate.cfg.xml [hibernatetool] 18:07:56680 INFO 配置:507 - 讀映射 從RES烏爾斯河:你好/ Message.hbm.xml [hibernatetool] 18:07:56758 INFO HbmBinder:300 - 映射類: hello.Message - > MESSAGES [hibernatetool] 18:07:56,851信息配置:1465 - 配置的SessionFactor y:null [hibernatetool] 18:07:56,851信息 方言:141 - 使用方言: org.hibernate.di alect.HSQLDialect [hibernatetool] 18:07:56914 INFO SchemaExport工具:154 - 運行就是hbm2ddl 架構EXP ORT [hibernatetool] 18:07:56914 INFO SchemaExport工具: 174 - 寫入生成的模式到文件: C:\用戶\拉梅什\桌面\教程\休眠\休眠 代碼樣本\ jpwh- gettingstarted-070401 \ HelloWorld的天然\的HelloWorld-ddl.sql [hibernatetool] 18: 07:56,914 INFO SchemaExport:179 - 導出生成 模式到數據庫[hibernatetool] 18:07:56,914信息 C3P0ConnectionProvider:50 - C3P0使用 驅動程序:在org.hsqldb.jdbcDriver URL: JDBC:HSQLDB:HSQL://本地主機 [hibernatetool] 18:07:56914 INFO C3P0ConnectionProvider:51 - 連接 正確關係:{用戶= SA} [hibernatetool] 18:07:56914 INFO C3P0ConnectionProvider:54 - 自動提交 模式:假[hibernatetool] 18:08:26554 WARN BasicResourcePool:1222 - com.mchange.v2.resou [email protected] - 收購嘗試失敗!清理未完成的採集。儘管 試圖獲取所需的新資源 資源,但我們仍然獲得了比最大允許獲取次數 (30)更多的 。 [hibernatetool] 18:08:26554 ERROR SchemaExport工具:202 - 架構出口 不成功
[hibernatetool]值java.sql.SQLException: 連接無法從 前作基礎數據庫獲取! [hibernatetool]在 com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.j AVA:104)[hibernatetool]在 com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.che ckoutPooledConnection(C3P0PooledConnectionPool.java :236) [hibernatetool]在 com.mchange.v2.c3p0.PoolBackedDataSource.getConnectio N(PoolBackedDataSource.java:94) 在[hibernatetool] org.hibernate.connection.C3P0ConnectionProvider.getCo nnection(C3P0ConnectionProvider.java :35) [hibernatetool] at org.hibernate.tool.hbm2ddl.ManagedProviderConnectionH elper.prepare(ManagedProviderConnectio nHelper.java:28) [hibernatetool]在 org.hibernate.tool.hbm2ddl.SchemaExport.execute(舍姆 aExport.java:180)[hibernatetool]
在 org.hibernate.tool.hbm2ddl.SchemaExport.create (模式 Export.java:133)[hibernatetool]
在 org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(血紅蛋白 m2DDLExporterTask.java:55) 在 org.hibernate.tool.ant [hibernatetool]。 HibernateToolTask.execute(Hibe rnateToolTask.java:171) [hibernatetool] at org.apache.tools.ant.UnknownElement.execute(UnknownEl ement.java:291)[hibernatetool]
在 sun.reflect.NativeMethodAccessorImpl.invoke0(母語 中號ethod)[hibernatetool]在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMet hodAccessorImpl.java:39) [ hibernatetool]在 sun.reflect.DelegatingMethodAccessorImpl.invoke(德勒 atingMethodAccessorImpl.java:25) [hibernatetool]在 java.lang.reflect.Method.invoke(Method.java:597) [hibernatetool]在 有機apache.tools.ant.dispatch.DispatchUtils.execute(D ispatchUtils.java:106)[hibernatetool] at org.apache.tools.ant.Task.perform(Task.java:348) [hibernatetool]在 org.apache.tools.ant.Target.execute(Target.java:390) [hibernatetool]在 有機.apache.tools.ant.Target.performTasks(Target.java: 411)[hibernatetool]在 org.apache.tools.ant.Project.executeSortedTargets(臨 ject.java:1397)[hibernatetool]
在 org.apache.tools.ant.Project.executeTarget(Project.ja VA:1366)[hibernatetool]在 org.apache.tools.ant.helper.DefaultExecutor.executeTa rgets(DefaultExecutor.java:41) [hibernatetool ]在 org.apac he.tools.ant.Project.executeTargets(Project.j AVA:1249)[hibernatetool]在 org.apache.tools.ant.Main.runBuild(Main.java:801) [hibernatetool]在 org.apache .tools.ant.Main.startAnt(Main.java:218) [hibernatetool] at org.apache.tools.ant.launch.Launcher.run(Launcher。JAV 一個:280)[hibernatetool]在 org.apache.tools.ant.launch.Launcher.main(Launcher.ja VA:109)[hibernatetool]所致: com.mchange.v2.resourcepool.CannotAcquireResourceExce ption:一個ResourcePool不能從 工廠或工廠獲取資源 。 [hibernatetool]
在 com.mchange.v2.resourcepool.BasicResourcePool.awaitAc 疊紙(BasicResourcePool.java:970) [hibernatetool]在 com.mchange.v2.resourcepool.BasicResourcePool.checkou tResource(BasicResourcePool.java :208) [hibernatetool]在 com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.che ckoutPooledConnection(C3P0PooledConnectionPool.java:232) [hibernatetool] ...同時執行時發生24更 [hibernatetool] 1個錯誤 。 [hibernatetool]錯誤#1: java.sql.SQLException:連接 無法從 底層數據庫中獲得! [hibernatetool] 18:08:26569 WARN BasicResourcePool:1222 - com.mchange.v2.resou [email protected] - 採集嘗試失敗!!!清理未完成的採集。雖然 試圖獲取所需的新 的資源,我們的固定資產投資導致成功超過允許 獲取嘗試(30)的最大數量.`
更 我沒有關於任何hiberate或太多的知識HSQL ..
有人請說明這裏有什麼錯?
感謝
編輯:我試圖運行項目helloworld-native
。
在startdb螞蟻的build.xml給出的目標是如下:
<!-- Start the HSQL DB server -->
<target name="startdb" description="Run HSQL database server with clean DB">
<!-- Delete database files -->
<delete dir="${database.dir}"/>
<java classname="org.hsqldb.Server"
fork="yes"
classpathref="project.classpath"
failonerror="true">
<arg value="-database.0"/>
<arg value="file:${database.dir}/db"/>
</java>
</target>
,當我運行命令ant startdb
我看到下面的輸出:
startdb:
[delete] Deleting directory C:\Users\Ramesh\Desktop\Tutorials\hibernate\Hibernate Code samples\jpwh-gettingstarted-070401\helloworld-native\database
[java] [[email protected]]: [Thread[main,5,main]]: checkRunning(false) entered
[java] [[email protected]]: [Thread[main,5,main]]: checkRunning(false) exited
[java] [[email protected]]: Startup sequence initiated from main() method
[java] [[email protected]]: Loaded properties from [C:\Users\Ramesh\Desktop\Tutorials hibernate\Hibernate Code samples\jpwh-gettingstarted-070401\helloworld-native\server.properties]
[java] [[email protected]]: Initiating startup sequence...
[java] [[email protected]]: Server socket opened successfully in 29 ms.
[java] [[email protected]]: Database [index=0, id=0, db=file:database/db, alias=] opened sucessfully in 469 ms.
[java] [[email protected]]: Startup sequence completed in 523 ms.
[java] [[email protected]]: 2010-11-08 22:11:08.027 HSQLDB server 1.8.0 is online
[java] [[email protected]]: To close normally, connect and execute SHUTDOWN SQL
[java] [[email protected]]: From command line, use [Ctrl]+[C] to abort abruptly
然後,我想我只在服務器模式下運行HSQL DB(從上面的輸出)..
請告訴我還有什麼我丟失..
嘗試與MySQL..and它工作..不知道什麼是probelm? – javanoob 2010-11-07 13:23:19