-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 
Author Message
 Post subject: Objects and Data not getting created/posted to HSQLDB
PostPosted: Wed Apr 26, 2006 7:19 am 
Newbie

Joined: Thu Apr 13, 2006 6:16 am
Posts: 11
Everything seems OK with 'create table', 'insert', 'drop table' etc. statements and commit, when I execute hibernate tutorials/samples. But nothing is written to the DB. No exceptions occur. The DB is created with lck, log, script, and properties file. Script file just has got
"CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET WRITE_DELAY 20".

Nothing more than this. When I open the DB using

"java org.hsqldb.util.DatabaseManager -driver org.hsqldb.jdbcDriver -url jdbc:hsqldb:data/auction -user sa"

I see an empty DB, with no objects, no data inserted, no data updated etc.

Tired of executing N hibernate tutorial and sample programs.

Find below details when I tried to execute 'auction eg' of hibernate3.1. Need help very badly.

Hibernate version: hibernate-3.1

Mapping documents: AuctionItem.hbm, Bid.hbm, User.hbm

Code between sessionFactory.openSession() and session.close():
Session s = factory.openSession();
Transaction tx = s.beginTransaction();

User seller = new User();
seller.setUserName("xam");
seller.setName( new Name("Max", new Character('R'), "Andersen") );
seller.setEmail("max@hibernate.org");
seller.setPassword("******");
seller.setAuctions( new ArrayList() );
s.save(seller);
tx.commit();
s.close();

Full stack trace of any exception that occurs: NO EXCEPTION, but for
Buildfile: build.xml
[taskdef] Could not load definitions from resource checkstyletask.properties. It could not be found.
[taskdef] Could not load definitions from resource clovertasks. It could not be found.

Name and version of the database you are using: HSQLDB 1.8

The generated SQL (show_sql=true):
[java] 16:36:06,250 DEBUG SchemaExport:301 -
[java] drop table AuctionItem if exists
[java] 16:36:06,250 DEBUG SchemaExport:301 -
[java] drop table AuctionUser if exists
[java] 16:36:06,265 DEBUG SchemaExport:301 -
[java] drop table Bid if exists
[java] 16:36:06,281 DEBUG SchemaExport:301 -
[java] create table AuctionItem (
[java] id bigint generated by default as identity (start with 1),
[java] seller bigint not null,
[java] shortDescription varchar(200) not null,
[java] description varchar(1000),
[java] ends timestamp,
[java] "CONDITION" integer,
[java] successfulBid bigint,
[java] primary key (id),
[java] unique (seller, shortDescription)
[java] )
[java] 16:36:06,343 DEBUG SchemaExport:301 -
[java] create table AuctionUser (
[java] id bigint generated by default as identity (start with 1),
[java] userName varchar(10) not null,
[java] "password" varchar(15) not null,
[java] email varchar(255),
[java] firstName varchar(50) not null,
[java] "initial" char(1),
[java] lastName varchar(50) not null,
[java] primary key (id),
[java] unique (userName)
[java] )
[java] 16:36:06,390 DEBUG SchemaExport:301 -
[java] create table Bid (
[java] id bigint generated by default as identity (start with 1),
[java] isBuyNow char(1) not null,
[java] item bigint not null,
[java] amount float not null,
[java] "datetime" timestamp not null,
[java] bidder bigint not null,
[java] primary key (id),
[java] unique (item, amount)
[java] )
[java] 16:36:06,421 DEBUG SchemaExport:301 -
[java] alter table AuctionItem
[java] add constraint FK522A9BD6F65B1FAF
[java] foreign key (successfulBid)
[java] references Bid
[java] 16:36:06,437 DEBUG SchemaExport:301 -
[java] alter table AuctionItem
[java] add constraint FK522A9BD61107FE9B
[java] foreign key (seller)
[java] references AuctionUser
[java] 16:36:06,453 DEBUG SchemaExport:301 -
[java] alter table Bid
[java] add constraint FK104DDF43A3910
[java] foreign key (bidder)
[java] references AuctionUser
[java] 16:36:06,468 DEBUG SchemaExport:301 -
.....
.....
.....
[java] insert
[java] into
[java] AuctionItem
[java] (seller, shortDescription, description, ends, "CONDITION", s
cessfulBid, id)
[java] values
[java] (?, ?, ?, ?, ?, ?, null)
[java] Hibernate:
[java] call identity()
[java] Hibernate:
[java] insert
[java] into
[java] Bid
[java] (item, amount, "datetime", bidder, isBuyNow, id)
[java] values
[java] (?, ?, ?, ?, 'N', null)
[java] Hibernate:
[java] call identity()
.....
.....
....
[java] Viewing auctions containing: DESC with condition: 8/10
[java] Item: 3 - new description

[java] 16:40:36,500 INFO SessionFactoryImpl:729 - closing
[java] 16:40:36,500 INFO DriverManagerConnectionProvider:147 - cleaning up
connection pool: jdbc:hsqldb:data/auction
[echo] Please follow the Getting Started road map: http://www.hibernate.org
/152.html

BUILD SUCCESSFUL
Total time: 4 minutes 48 seconds


Debug level Hibernate log excerpt: log4j.logger.org.hibernate=info

hibernate.properties: hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.connection.driver_class=org.hsqldb.jdbcDriver
hibernate.connection.url=jdbc:hsqldb:data/auction
hibernate.connection.username=sa
hibernate.connection.password=


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 12:58 pm 
Newbie

Joined: Wed Apr 26, 2006 8:28 am
Posts: 8
Location: Germany
I think you are using HSQLDB in memory mode.
Try this:
Code:
hibernate.connection.url=jdbc:hsqldb:hsql://localhost/data/auction


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 1:40 pm 
Newbie

Joined: Thu Apr 13, 2006 6:16 am
Posts: 11
Thanks for the info. But it did not work. On using
hibernate.connection.url=jdbc:hsqldb:hsql://localhost/data/auction, I got to see the following errors. Any inputs pls.

==========================================

[java] 23:13:02,031 INFO SchemaExport:152 - Running hbm2ddl schema export
[java] 23:13:02,046 DEBUG SchemaExport:168 - import file not found: /import
.sql
[java] 23:13:02,046 INFO SchemaExport:177 - exporting generated schema to
database
[java] 23:13:02,984 ERROR SchemaExport:200 - schema export unsuccessful
[java] java.sql.SQLException: socket creation error
[java] at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
[java] at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
[java] at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
[java] at org.hsqldb.jdbcDriver.connect(Unknown Source)
[java] at java.sql.DriverManager.getConnection(DriverManager.java:525)
[java] at java.sql.DriverManager.getConnection(DriverManager.java:140)
[java] at org.hibernate.connection.DriverManagerConnectionProvider.getC
onnection(DriverManagerConnectionProvider.java:110)
[java] at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnecti
onHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:27)
[java] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.
java:178)
[java] at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.j
ava:131)
[java] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryIm
pl.java:295)
[java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configura
tion.java:1176)
[java] at org.hibernate.auction.Main.main(Main.java:371)
[java] Setting up some test data
[java] 23:13:04,093 WARN JDBCExceptionReporter:71 - SQL Error: -80, SQLSta
te: 08000
[java] 23:13:04,093 ERROR JDBCExceptionReporter:72 - socket creation error
[java] Exception in thread "main" org.hibernate.exception.JDBCConnectionExc
eption: Cannot open connection


Top
 Profile  
 
 Post subject: Could not obtain connection - Metadata
PostPosted: Wed Apr 26, 2006 1:49 pm 
Newbie

Joined: Thu Apr 13, 2006 6:16 am
Posts: 11
setting hibernate URL in the following way

"hibernate.connection.url=jdbc:hsqldb:hsql://localhost/data/auction

resulted in "could not obtain connection metadata"

Appreciate cooperation


[java] 23:12:59,171 INFO DriverManagerConnectionProvider:80 - using driver
: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:hsql://localhost/data/auction
[java] 23:12:59,171 INFO DriverManagerConnectionProvider:86 - connection p
roperties: {user=sa, password=****}
[java] 23:13:00,718 WARN SettingsFactory:103 - Could not obtain connection
metadata
[java] java.sql.SQLException: socket creation error
[java] at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
[java] at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
[java] at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
[java] at org.hsqldb.jdbcDriver.connect(Unknown Source)
[java] at java.sql.DriverManager.getConnection(DriverManager.java:525)
[java] at java.sql.DriverManager.getConnection(DriverManager.java:140)
[java] at org.hibernate.connection.DriverManagerConnectionProvider.getC
onnection(DriverManagerConnectionProvider.java:110)
[java] at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFacto
ry.java:72)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 5:31 am 
Newbie

Joined: Wed Apr 26, 2006 8:28 am
Posts: 8
Location: Germany
I was successful with HSQLDB 1.8.0 and an URL like hsql://localhost/data, meaning a simple single path. Be also sure to use the same jar-file for the server and the client, otherwise you will receive socket errors.


Top
 Profile  
 
 Post subject: Objects and Data is not getting created/posted to HSQLDB
PostPosted: Thu Apr 27, 2006 6:09 am 
Newbie

Joined: Thu Apr 13, 2006 6:16 am
Posts: 11
Thanks again. But, it did not work for me. I do not think 1.8x is anyway different in handling this.

Secondly, I'm not clear of "use same jar file for the server and the client - causing socket errors'. Pls. explain.

Thirdly, "http://examples.oreilly.com/hibernate/" says the following. Is it correct? If yes, how to proceed with db population in hibernate3x with hsqldb1.8, any input?

"The Hibernate Extensions don't seem to currently work with HSQLDB
1.8.0 RC5; although the schema appears to be generated in the output
from "ant schema", the database remains empty."


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 6:28 am 
Newbie

Joined: Wed Apr 26, 2006 8:28 am
Posts: 8
Location: Germany
Sorry, sorry, I thought you are using HSQLDB in server mode, so forget about everything.
Yes, maybe it is just the version of HSQLDB and you should try 1.8.0 final.


Top
 Profile  
 
 Post subject: Objects and Data is not getting created/posted to HSQLDB
PostPosted: Thu Apr 27, 2006 6:36 am 
Newbie

Joined: Thu Apr 13, 2006 6:16 am
Posts: 11
Thanks a ton for instant replies.

Will you pls. explain me "using HSQLDB in server mode". I'm relatively new to hibernate n hsqldb. Will download and install 1.8.0 final then.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 8:33 am 
Newbie

Joined: Wed Apr 26, 2006 8:28 am
Posts: 8
Location: Germany
You can start HSQLDB as a server:
Code:
java org.hsqldb.Server -database.0 corporate -dbname.0 corporatedb

and connect your client app to the server via
Code:
jdbc:hsqldb:hsql://localhost/corporatedb

That means you havn't an embedded database but a database server.


Top
 Profile  
 
 Post subject: Objects and Data is not getting created/posted to HSQLDB
PostPosted: Thu Apr 27, 2006 9:12 am 
Newbie

Joined: Thu Apr 13, 2006 6:16 am
Posts: 11
Thanks a lot, Tlueckow.

I could successfully start HSQLDB server for auctiondb on localhost.

Edited hibernate.properites for db url

hibernate.connection.url=jdbc:hsqldb:hsql://localhost/auctiondb

My 'eg', hibernate-3.1 sample application got executed successfully (as usual). But, with a difference that the objects and records being inserted in to the database.

I could countercheck the db objects and records of 'auctiondb' using

java org.hsqldb.util.DatabaseManager -driver org.hsqldb.jdbcDriver -url jdbc:hsqldb:hsql://localhost/auctiondb

I'm happy to proceed a step ahead.

One thing what i'm not getting to understand is the location of the database. The db is not getting created in my application, respective folder. Where does it get created by default? Is there any way that I can specify its existence in a specific folder of my Windows system using server.properties?

Awaiting to have some input.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 10:00 am 
Newbie

Joined: Wed Apr 26, 2006 8:28 am
Posts: 8
Location: Germany
I think we should stop here, because we are actually not discussing a hibernate problem.

You can specify the path of the database at server startup, eg. under Windows:

Code:
java -cp d:\opt\hsqldb\lib\hsqldb.jar org.hsqldb.Server -database.0 file:///C:/db/corporate -dbname.0 corporatedb


If you don't specify a path, the database is created at that location where you start the server with the java command.


Top
 Profile  
 
 Post subject: Objects and Data is not getting created/posted to HSQLDB
PostPosted: Thu Apr 27, 2006 10:37 am 
Newbie

Joined: Thu Apr 13, 2006 6:16 am
Posts: 11
Done!

Got to have fair understanding of hsqldb, to go with hibernate3x

I'll stop here and focus on to hibernate issues.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.