Я пытаюсь изучить Hibernate из Java Persistence с помощью hibernate Гэвина Кинга.
Я только что загрузил примеры, приведенные в книге, по этому адресу http://downloads.jboss.org/hibernate/caveatemptor/jpwh-gettingstarted-070401.zip
Я запустил базу данных HSQL с помощью ant startdb, и база данных успешно запустилась.
При попытке запустить целевой экспорт схемы я получаю следующую ошибку.
schemaexport: [hibernatetool] Запуск Hibernate Tool со стандартной конфигурацией [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 und [hibernatetool] 18:07:56,555 INFO Environment:667 - Имя поставщика байт-кода: cg lib [hibernatetool] 18:07:56,571 INFO Environment:584 - использование JDK 1.4 java. Обработка отметок времени sql.Time [hibernatetool] 18:07:56,617 Конфигурация INFO:1384 — настройка из файла: h ibernate.cfg.xml [hibernatetool] 18:07:56,680 Конфигурация INFO:507 — Чтение сопоставлений из ресурсов: hello/Message .hbm.xml [hibernatetool] 18:07:56,758 INFO HbmBinder:300 — класс сопоставления: hello.Message -> MESSAGES [hibernatetool] 18:07:56,851 INFO Configuration: 1465 — Configured SessionFactor y: null [hibernatetool] 18:07 :56,851 ИНФОРМАЦИЯ Диалект:141 - Использование диалекта: org.hibernate. di alect.HSQLDialect [hibernatetool] 18:07:56,914 INFO SchemaExport:154 - Запуск экспорта схемы hbm2ddl [hibernatetool] 18:07:56,914 INFO SchemaExport:174 - Запись сгенерированной схемы в файл: C:\Users\Ramesh\Desktop\ Tutorials\hibernate\Hibernate Code examples\jpwh-getstarted-070401\helloworld-native\helloworld-ddl.sql [hibernatetool] 18:07:56,914 INFO SchemaExport:179 — экспорт сгенерированной схемы в базу данных [hibernatetool] 18:07:56,914 INFO C3P0ConnectionProvider:50 — C3P0 с использованием драйвера: org.hsqldb.jdbcDriver по URL-адресу: jdbc:hsqldb:hsql://localhost [hibernatetool] 18:07:56,914 INFO C3P0ConnectionProvider:51 — свойства подключения: {user=sa} [hibernatetool] 18:07:56,914 INFO C3P0ConnectionProvider:54 — режим автоматической фиксации: false [hibernatetool] 18:08:26,554 WARN BasicResourcePool:1222 — com.mchange.v2.resou rcepool.BasicResourcePool$AcquireTask@61f1680f — попытка получения не удалась!!! Очистка ожидающих приобретения. При попытке получить необходимый новый ресурс нам не удалось добиться успеха больше, чем максимально допустимое количество попыток получения (30). [hibernatetool] 18:08:26,554 ОШИБКА SchemaExport:202 - неудачный экспорт схемы
У меня нет слишком много знаний ни о спящем режиме, ни о HSQL.
Кто-нибудь объясните, что здесь не так??
Спасибо
EDIT: я пытаюсь запустить проект helloworld-native
.
Цель, указанная в файле ant build.xml для startdb, выглядит следующим образом:
и когда я запускаю команду ant startdb
, я вижу следующий вывод:
<!-- 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>
Затем я думаю, что запускаю БД HSQL только в режиме сервера (из приведенного выше вывода).
startdb:
[delete] Deleting directory C:\Users\Ramesh\Desktop\Tutorials\hibernate\Hibernate Code samples\jpwh-gettingstarted-070401\helloworld-native\database
[java] [Server@15ded0fd]: [Thread[main,5,main]]: checkRunning(false) entered
[java] [Server@15ded0fd]: [Thread[main,5,main]]: checkRunning(false) exited
[java] [Server@15ded0fd]: Startup sequence initiated from main() method
[java] [Server@15ded0fd]: Loaded properties from [C:\Users\Ramesh\Desktop\Tutorials hibernate\Hibernate Code samples\jpwh-gettingstarted-070401\helloworld-native\server.properties]
[java] [Server@15ded0fd]: Initiating startup sequence...
[java] [Server@15ded0fd]: Server socket opened successfully in 29 ms.
[java] [Server@15ded0fd]: Database [index=0, id=0, db=file:database/db, alias=] opened sucessfully in 469 ms.
[java] [Server@15ded0fd]: Startup sequence completed in 523 ms.
[java] [Server@15ded0fd]: 2010-11-08 22:11:08.027 HSQLDB server 1.8.0 is online
[java] [Server@15ded0fd]: To close normally, connect and execute SHUTDOWN SQL
[java] [Server@15ded0fd]: From command line, use [Ctrl]+[C] to abort abruptly
Подскажите, что еще мне не хватает..
Обновление: при повторном рассмотрении оказывается, что я был неправ, вы можете запустить HSQL в режиме сервера с помощью ant-скрипта, и вам не обязательно использовать командную строку. На самом деле, я пытался воспроизвести проблему с образцом helloworld-native
, но у меня это сработало.