Hibernate version: 3.1
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Name and version of the database you are using: hsqldb
-----------------------------------------------------
In my program i've the following error:
The error
Code:
Full stack trace of any exception that occurs:
12:16:06,185 WARN SettingsFactory:103 - Could not obtain connection metadata
java.sql.SQLException: socket creation error
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
at org.hsqldb.jdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)
at com.sample.jbpm.hibernate.util.HibernateUtil.<clinit>(HibernateUtil.java:23)
at com.sample.jbpm.hibernate.GestorEntradas.createAndStoreEvent(GestorEntradas.java:14)
at com.sample.jbpm.hibernate.GestorEntradas.main(GestorEntradas.java:41)
12:16:06,200 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
12:16:06,216 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
12:16:06,216 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
12:16:06,216 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
12:16:06,216 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
12:16:06,216 INFO SettingsFactory:144 - Scrollable result sets: disabled
12:16:06,216 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
12:16:06,216 INFO SettingsFactory:160 - Connection release mode: null
12:16:06,216 INFO SettingsFactory:184 - Maximum outer join fetch depth: 1
12:16:06,216 INFO SettingsFactory:187 - Default batch fetch size: 1
12:16:06,216 INFO SettingsFactory:191 - Generate SQL with comments: disabled
12:16:06,216 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
12:16:06,247 INFO SettingsFactory:334 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
12:16:06,263 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
12:16:06,263 INFO SettingsFactory:203 - Query language substitutions: {}
12:16:06,263 INFO SettingsFactory:209 - Second-level cache: enabled
12:16:06,263 INFO SettingsFactory:213 - Query cache: disabled
12:16:06,263 INFO SettingsFactory:321 - Cache provider: org.hibernate.cache.HashtableCacheProvider
12:16:06,263 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
12:16:06,263 INFO SettingsFactory:233 - Cache region prefix: hibernate.test
12:16:06,263 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
12:16:06,263 INFO SettingsFactory:257 - Echoing all SQL to stdout
12:16:06,263 INFO SettingsFactory:261 - Statistics: disabled
12:16:06,263 INFO SettingsFactory:265 - Deleted entity synthetic identifier rollback: disabled
12:16:06,263 INFO SettingsFactory:279 - Default entity-mode: pojo
12:16:06,388 INFO SessionFactoryImpl:152 - building session factory
12:16:06,403 WARN CacheFactory:43 - read-only cache configured for mutable class: hibernate.test.com.sample.jbpm.hibernate.TabelaGestaoOcorrencias
12:16:06,700 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
12:16:06,700 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
12:16:06,716 INFO Configuration:875 - processing extends queue
12:16:06,716 INFO Configuration:879 - processing collection mappings
12:16:06,716 INFO Configuration:888 - processing association property references
12:16:06,716 INFO Configuration:917 - processing foreign key constraints
12:16:06,716 INFO Configuration:875 - processing extends queue
12:16:06,716 INFO Configuration:879 - processing collection mappings
12:16:06,716 INFO Configuration:888 - processing association property references
12:16:06,716 INFO Configuration:917 - processing foreign key constraints
12:16:06,716 INFO SchemaExport:113 - Running hbm2ddl schema export
12:16:06,716 INFO SchemaExport:129 - exporting generated schema to database
12:16:06,716 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
12:16:06,716 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
12:16:06,716 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
12:16:06,716 INFO DriverManagerConnectionProvider:80 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:hsql://localhost:5432
12:16:06,716 INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****}
12:16:07,607 ERROR SchemaExport:179 - schema export unsuccessful
java.sql.SQLException: socket creation error
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
at org.hsqldb.jdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:432)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:130)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:99)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:264)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at com.sample.jbpm.hibernate.util.HibernateUtil.<clinit>(HibernateUtil.java:23)
at com.sample.jbpm.hibernate.GestorEntradas.createAndStoreEvent(GestorEntradas.java:14)
at com.sample.jbpm.hibernate.GestorEntradas.main(GestorEntradas.java:41)
12:16:07,607 INFO SessionFactoryImpl:379 - Checking 0 named queries
12:16:07,607 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:hsqldb:hsql://localhost:5432
Exception in thread "main" org.hibernate.HibernateException: No TransactionManagerLookup specified
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:503)
at com.sample.jbpm.hibernate.GestorEntradas.createAndStoreEvent(GestorEntradas.java:14)
at com.sample.jbpm.hibernate.GestorEntradas.main(GestorEntradas.java:41)
Here are all the files of the program.
GestorEntradas.javaCode:
package com.sample.jbpm.hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import java.util.Date;
import com.sample.jbpm.hibernate.util.HibernateUtil;
public class GestorEntradas {
private void createAndStoreEvent() {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
Transaction tx;
try{
tx = session.beginTransaction();
TabelaGestaoOcorrencias theEvent = new TabelaGestaoOcorrencias();
theEvent.setDataocorrencia("01/01/2005");
theEvent.setHoraocorrencia("12:00");
theEvent.setTipoocorrencia("Acidente");
theEvent.setObservacoes("Teste");
session.save(theEvent);
tx.commit();
}
catch(Exception e){
// TODO
}
finally{
session.close();
}
}
public static void main(String[] args) {
GestorEntradas mgr = new GestorEntradas();
mgr.createAndStoreEvent();
HibernateUtil.getSessionFactory().close();
}
}
SessionFactory.javaCode:
import org.hibernate.*;
import org.hibernate.cfg.*;
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
/*
* It's time to load and store some Event objects,
* but first we have to complete the setup with some
* infrastructure code. We have to startup Hibernate.
* This startup includes building a global SessionFactory
* object and to store it somewhere for easy access
* in application code. A SessionFactory can open up new Session's.
* A Session represents a single-threaded unit of work,
* the SessionFactory is a thread-safe global object, instantiated once.
*/
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
hibernate.cfg.xmlCode:
<?xml version='1.0' ?><!-- Não por uma linha em branco entre o xml version e o DOCTYPE -->
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Echo all executed SQL to stdout -->
<property name="hibernate.show_sql">true</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<!--identity mapping files -->
<mapping resource="com/sample/jbpm/hibernate/TabelaGestaoOcorrencias.hbm.xml"/>
</session-factory>
</hibernate-configuration>
hibernate.propertiesCode:
######################
### Query Language ###
######################
## define query language constants / function names
#hibernate.query.substitutions yes 'Y', no 'N'
## select the classic query parser
#hibernate.query.factory_class org.hibernate.hql.classic.ClassicQueryTranslatorFactory
#################
### Platforms ###
#################
## HypersonicSQL
# SQL dialect
hibernate.dialect org.hibernate.dialect.HSQLDialect
# jdbc connection properties
hibernate.connection.driver_class org.hsqldb.jdbcDriver
hibernate.connection.username sa
hibernate.connection.password
hibernate.connection.url jdbc:hsqldb:hsql://localhost:5432
#################################
### Hibernate Connection Pool ###
#################################
hibernate.connection.pool_size 1
##############################
### Proxool Connection Pool###
##############################
## Properties for external configuration of Proxool
hibernate.proxool.pool_alias pool1
#################################
### Plugin ConnectionProvider ###
#################################
## use a custom ConnectionProvider (if not set, Hibernate will choose a built-in ConnectionProvider using hueristics)
#hibernate.connection.provider_class org.hibernate.connection.DriverManagerConnectionProvider
#hibernate.connection.provider_class org.hibernate.connection.DatasourceConnectionProvider
#hibernate.connection.provider_class org.hibernate.connection.C3P0ConnectionProvider
#hibernate.connection.provider_class org.hibernate.connection.ProxoolConnectionProvider
#######################
### Transaction API ###
#######################
## the Transaction API abstracts application code from the underlying JTA or JDBC transactions
#hibernate.transaction.factory_class org.hibernate.transaction.JTATransactionFactory
#hibernate.transaction.factory_class org.hibernate.transaction.JDBCTransactionFactory
## to use JTATransactionFactory, Hibernate must be able to locate the UserTransaction in JNDI
## default is java:comp/UserTransaction
## you do NOT need this setting if you specify hibernate.transaction.manager_lookup_class
## to use the second-level cache with JTA, Hibernate must be able to obtain the JTA TransactionManager
org.hibernate.transaction.JBossTransactionManagerLookup
org.hibernate.transaction.WeblogicTransactionManagerLookup
org.hibernate.transaction.WebSphereTransactionManagerLookup
org.hibernate.transaction.OrionTransactionManagerLookup
org.hibernate.transaction.ResinTransactionManagerLookup
##############################
### Miscellaneous Settings ###
##############################
## format SQL in log and console
hibernate.format_sql true
## set the maximum depth of the outer join fetch tree
hibernate.max_fetch_depth 1
#####################
### JDBC Settings ###
#####################
## enable batch updates even for versioned data
hibernate.jdbc.batch_versioned_data true
## enable use of JDBC 2 scrollable ResultSets (specifying a Dialect will cause Hibernate to use a sensible default)
## use streams when writing binary types to / from JDBC
hibernate.jdbc.use_streams_for_binary true
## use JDBC 3 PreparedStatement.getGeneratedKeys() to get the identifier of an inserted row
##########################
### Second-level Cache ###
##########################
## optimize chache for minimal "puts" instead of minimal "gets" (good for clustered cache)
## set a prefix for cache region names
hibernate.cache.region_prefix hibernate.test
## choose a cache implementation
hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
org.hibernate.cache.SwarmCacheProvider
############
### JNDI ###
############
## specify a JNDI name for the SessionFactory
#hibernate.session_factory_name hibernate/session_factory
## Hibernate uses JNDI to bind a name to a SessionFactory and to look up the JTA UserTransaction;
## if hibernate.jndi.* are not specified, Hibernate will use the default InitialContext() which
## is the best approach in an application server
#WebSphere
com.ibm.websphere.naming.WsnInitialContextFactory
I don't know what should i do to resolve this problem. Any suggestion?
Thanks,
Pedro