Connections cannot be retrieved from the base database! - HSQL DB

I am trying to learn Hibernate from Java Persistence with hibernate from Gavin King.

I just downloaded the examples in a book from this location http://downloads.jboss.org/hibernate/caveatemptor/jpwh-gettingstarted-070401.zip

I started my HSQL db with ant startdb and the database started successfully.

When I try to start the target schemaexport, I get the following error.

schemaexport: [hibernatetool] Running the Hibernate tool using Standard configuration [hibernatetool] 1. task: hbm2ddl (generates the database schema) [hibernatetool] 18: 07: 56,555 INFO Environment: 500 - Sleep 3.2.0.cr5 [hibernatetool] 18: 07: 56,555 INFO Environment: 533 - hibernate.properties not fo und [hibernatetool] 18: 07: 56,555 INFO Environment: 667 - Bytecode provider name: cg lib [hibernatetool] 18: 07: 56,571 INFO Environment: 584 - using JDK 1.4 java.sql.Time stamp processing [hibernatetool] 18: 07: 56,617 INFO configuration: 1384 - setting from file: h ibernate.cfg.xml [hibernatetool] 18: 07: 56,680 INFO Configuration: 507 - Reading from views res ource: hello / Message.hbm.xml [hibernatetool] 18: 07: 56,758 INFO HbmBinder: 300 - Display class: hello.Message → MESSAGES [hibernatetool] 18: 07: 56,851 INFO configuration: 1465 - Configured SessionFactor y: null [hibernatetool] 18: 07: 56,851 INFO Dialect: 141 - Using dialect: org.hibernate.di alect.HSQLDialect [hibernatetool] 18: 07: 56,914 INFO SchemaExport: 154 - Running hbm2ddl schema exp ort [hibernatetool] 18: 07: 56,914 INFO SchemaExport: 174 - writing the generated schema to file: C: \ Users \ Ramesh \ Desktop \ Tutorials \ sleep mode \ Hibernate Code samples \ jpwh- GettingStarted-070401 \ HelloWorld native \ HelloWorld-ddl.sql [hibernatetool] 18: 07: 56,914 INFO SchemaExport: 179 - the generated schema is exported to the [hibernatetool] database 18: 07: 56,914 INFO C3P0ConnectionProvider: 50 - : org.hsqldb.jdbcDriver at: JDBC: HSQLDB: HSQL: // local [hibernatetool] 18: 07: 56,914 INFO C3P0ConnectionProvider: 51 - Connecting the correct connection: {user = sa} [hibernatetool] 18: 07: 56,914 INFO C3P0ConnectionProvider: 54 - autocommit mode: false [hibernatetool] 18: 08: 26,554 WARN BasicResourcePool: 1222 - com.mchange.v2 .resourcepool.BasicResourcePool$AcquireTask@61f1680f - Error while purchasing! Cleaning up pending acquisitions. While trying to acquire the necessary new resource, we achieved success even more than the maximum number of permitted acquisition attempts (30). [hibernatetool] 18: 08: 26,554 ERROR SchemaExport: 202 - schema export failed

[hibernatetool] java.sql.SQLException: ! [hibernatetool] com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.j ava: 104) [hibernatetool] at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.che ckoutPooledConnection (C3P0PooledConnectionPool.java:236) [hibernatetool] com.mchange.v2.c3p0.PoolBackedDataSource.getConnectio (PoolBackedDataSource.java:94) [hibernatetool] org.hibernate.connection.C3P0ConnectionProvider.getCo (C3P0ConnectionProvider.java:35) [hibernatetool] org.hibernate.tool.hbm2ddl.ManagedProviderConnectionH elper.prepare(ManagedProviderConnectionHelper.java:28) [hibernatetool] org.hibernate.tool.hbm2ddl.SchemaExport.execute( aExport.java:180) [hibernatetool]
org.hibernate.tool.hbm2ddl.SchemaExport.create(Schema Export.java:133) [hibernatetool]
org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hb m2DDLExporterTask.java:55) [hibernatetool] org.hibernate.tool.ant.HibernateToolTask.execute(Hibe rnateToolTask.java:171) [hibernatetool] org.apache.tools.ant.UnknownElement.execute(UnknownEl ement.java:291) [hibernatetool]
sun.reflect.NativeMethodAccessorImpl.invoke0 (Native M ethod) [hibernatetool] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMet hodAccessorImpl.java:39) [hibernatetool] sun.reflect.DelegatingMethodAccessorImpl.invoke(Deleg atingMethodAccessorImpl.java:25) [hibernatetool] java.lang.reflect.Method.invoke(Method.java:597) [hibernatetool] org.apache.tools.ant.dispatch.DispatchUtils.execute( ispatchUtils.java:106) [hibernatetool] org.apache.tools.ant.Task.perform(Task.java:348) [hibernatetool] org.apache.tools.ant.Target.execute(Target.java:390) [hibernatetool] org.apache.tools.ant.Target.performTasks(Target.java: 411) [hibernatetool] org.apache.tools.ant.Project.executeSortedTargets(Pro ject.java:1397) [hibernatetool]
org.apache.tools.ant.Project.executeTarget(Project.ja va: 1366) [hibernatetool] at org.apache.tools.ant.helper.DefaultExecutor.executeTa rgets (DefaultExecutor.java:41) [hibernatetool] org.apache.tools.ant.Project.executeTargets(Project.j ava: 1249) [hibernatetool] at org.apache.tools.ant.Main.runBuild(Main.java:801) [hibernatetool] org.apache.tools.ant.Main.startAnt(Main.java:218) [hibernatetool] org.apache.tools.ant.launch.Launcher.run(Launcher.jav a: 280) [hibernatetool] at org.apache.tools.ant.launch.Launcher.main(Launcher.ja va: 109) [hibernatetool] : com.mchange.v2.resourcepool.CannotAcquireResourceExce ption: ResourcePool factory s ource. [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: 26,569 WARN BasicResourcePool: 1222 - com.mchange.v2.resou rcepool.BasicResourcePool$AcquireTask@72f864fe - ! . , (30).

hiberate HSQL.

-, , , ?

EDIT: helloworld-native.

, ant build.xml 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>

ant startdb, :

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 DB ( ).

, , .

+3
1

:. , , HSQL ant script, , , helloworld-native, .

HSQLDB , ant startdb:

$ ant startdb 
Buildfile: /home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/build.xml

startdb:
     [java] [Server@a97b0b]: [Thread[main,5,main]]: checkRunning(false) entered
     [java] [Server@a97b0b]: [Thread[main,5,main]]: checkRunning(false) exited
     [java] [Server@a97b0b]: Startup sequence initiated from main() method
     [java] [Server@a97b0b]: Loaded properties from [/home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/server.properties]
     [java] [Server@a97b0b]: Initiating startup sequence...
     [java] [Server@a97b0b]: Server socket opened successfully in 39 ms.
     [java] [Server@a97b0b]: Database [index=0, id=0, db=file:database/db, alias=] opened sucessfully in 1148 ms.
     [java] [Server@a97b0b]: Startup sequence completed in 1281 ms.
     [java] [Server@a97b0b]: 2010-11-08 18:29:20.094 HSQLDB server 1.8.0 is online
     [java] [Server@a97b0b]: To close normally, connect and execute SHUTDOWN SQL
     [java] [Server@a97b0b]: From command line, use [Ctrl]+[C] to abort abruptly

ant schemaexport :

$ ant schemaexport 
Buildfile: /home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/build.xml

compile:
    [mkdir] Created dir: /home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/build
    [javac] /home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/build.xml:39: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 3 source files to /home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/build

copymetafiles:
     [copy] Copying 3 files to /home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/build

schemaexport:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] 
[hibernatetool]     alter table MESSAGES 
[hibernatetool]         drop constraint FK_NEXT_MESSAGE;
[hibernatetool] 
[hibernatetool]     drop table MESSAGES if exists;
[hibernatetool] 
[hibernatetool]     create table MESSAGES (
[hibernatetool]         MESSAGE_ID bigint generated by default as identity (start with 1),
[hibernatetool]         MESSAGE_TEXT varchar(255),
[hibernatetool]         NEXT_MESSAGE_ID bigint,
[hibernatetool]         primary key (MESSAGE_ID)
[hibernatetool]     );
[hibernatetool] 
[hibernatetool]     alter table MESSAGES 
[hibernatetool]         add constraint FK_NEXT_MESSAGE 
[hibernatetool]         foreign key (NEXT_MESSAGE_ID) 
[hibernatetool]         references MESSAGES;
[hibernatetool] 1 errors occurred while performing <hbm2ddl>.
[hibernatetool] Error #1: java.sql.SQLException: Table not found: MESSAGES in statement [alter table MESSAGES]

BUILD SUCCESSFUL
Total time: 14 seconds

, ant dbmanager MESSAGES, .

, , . , , , , ..


, , HSQL ( , ), , , . , helloworld-reverse ( " HSQL", . 98):

$ java -cp lib/hsqldb.jar org.hsqldb.Server

jdbc:hsqldb:hsql://localhost.

+1

Source: https://habr.com/ru/post/1773495/


All Articles