-->
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.  [ 7 posts ] 
Author Message
 Post subject: help pls -- connection error
PostPosted: Sat May 15, 2010 8:26 am 
Newbie

Joined: Sat May 15, 2010 8:21 am
Posts: 4
hy, i just start using hibernate and i have a problem

i have this cfg.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="sessionFactory">
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driber</property>
<property name="hibernate.connection.autocommitt">true</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
<property name="connection.username">root</property>
<property name="connection.password">mami</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.current_session_context_class">thread</property>
<mapping resource="beans/Color.hbm.xml" />
</session-factory>
</hibernate-configuration>






and i receive this message

15:17:44,113 INFO Environment:570 - Hibernate 3.5.2-Final
15:17:44,117 INFO Environment:603 - hibernate.properties not found
15:17:44,126 INFO Environment:781 - Bytecode provider name : javassist
15:17:44,131 INFO Environment:662 - using JDK 1.4 java.sql.Timestamp handling
15:17:44,276 INFO Configuration:1552 - configuring from file: hibernate.cfg.xml
15:17:44,415 INFO Configuration:655 - Reading mappings from resource : beans/Color.hbm.xml
15:17:44,504 INFO HbmBinder:348 - Mapping class: beans.Color -> colors
15:17:44,527 INFO Configuration:1633 - Configured SessionFactory: sessionFactory
15:17:44,603 INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!)
15:17:44,603 INFO DriverManagerConnectionProvider:65 - Hibernate connection pool size: 20
15:17:44,603 INFO DriverManagerConnectionProvider:68 - autocommit mode: false
15:17:44,608 INFO DriverManagerConnectionProvider:103 - using driver: net.sourceforge.jtds.jdbc.Driver at URL: jdbc:jtds:sqlserver://localhost:1433/ISS
15:17:44,609 INFO DriverManagerConnectionProvider:109 - connection properties: {autocommitt=true}
15:17:45,663 WARN SettingsFactory:137 - Could not obtain connection to query metadata
java.sql.SQLException: Network error IOException: Connection refused: connect
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:410)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:114)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)
at utils.HibernateUtil.<clinit>(HibernateUtil.java:16)
at Main.main(Main.java:9)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:307)
at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:257)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:311)
... 11 more
15:17:45,700 INFO Dialect:206 - Using dialect: org.hibernate.dialect.MySQLDialect
15:17:45,707 INFO JdbcSupportLoader:70 - Disabling contextual LOB creation as connection was null
15:17:45,709 INFO TransactionFactoryFactory:59 - Using default transaction strategy (direct JDBC transactions)
15:17:45,711 INFO TransactionManagerLookupFactory:80 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
15:17:45,711 INFO SettingsFactory:169 - Automatic flush during beforeCompletion(): disabled
15:17:45,711 INFO SettingsFactory:173 - Automatic session close at end of transaction: disabled
15:17:45,712 INFO SettingsFactory:188 - Scrollable result sets: disabled
15:17:45,714 INFO SettingsFactory:196 - JDBC3 getGeneratedKeys(): disabled
15:17:45,714 INFO SettingsFactory:204 - Connection release mode: auto
15:17:45,715 INFO SettingsFactory:228 - Maximum outer join fetch depth: 2
15:17:45,715 INFO SettingsFactory:231 - Default batch fetch size: 1
15:17:45,716 INFO SettingsFactory:235 - Generate SQL with comments: disabled
15:17:45,716 INFO SettingsFactory:239 - Order SQL updates by primary key: disabled
15:17:45,716 INFO SettingsFactory:243 - Order SQL inserts for batching: disabled
15:17:45,717 INFO SettingsFactory:410 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
15:17:45,719 INFO ASTQueryTranslatorFactory:47 - Using ASTQueryTranslatorFactory
15:17:45,720 INFO SettingsFactory:251 - Query language substitutions: {}
15:17:45,720 INFO SettingsFactory:256 - JPA-QL strict compliance: disabled
15:17:45,720 INFO SettingsFactory:261 - Second-level cache: enabled
15:17:45,720 INFO SettingsFactory:265 - Query cache: disabled
15:17:45,720 INFO SettingsFactory:395 - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
15:17:45,721 INFO SettingsFactory:275 - Optimize cache for minimal puts: disabled
15:17:45,721 INFO SettingsFactory:284 - Structured second-level cache entries: disabled
15:17:45,727 INFO SettingsFactory:313 - Statistics: disabled
15:17:45,727 INFO SettingsFactory:317 - Deleted entity synthetic identifier rollback: disabled
15:17:45,728 INFO SettingsFactory:332 - Default entity-mode: pojo
15:17:45,728 INFO SettingsFactory:336 - Named query checking : enabled
15:17:45,728 INFO SettingsFactory:340 - Check Nullability in Core (should be disabled when Bean Validation is on): enabled
15:17:45,781 INFO SessionFactoryImpl:199 - building session factory
15:17:46,046 INFO SessionFactoryObjectFactory:109 - Factory name: sessionFactory
15:17:46,047 INFO NamingHelper:49 - JNDI InitialContext properties:{}
15:17:46,050 WARN SessionFactoryObjectFactory:121 - Could not bind factory to JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getNameParser(Unknown Source)
at org.hibernate.util.NamingHelper.bind(NamingHelper.java:75)
at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:113)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:376)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1385)
at utils.HibernateUtil.<clinit>(HibernateUtil.java:16)
at Main.main(Main.java:9)
15:17:47,159 WARN JDBCExceptionReporter:100 - SQL Error: 0, SQLState: 08S01
15:17:47,159 ERROR JDBCExceptionReporter:101 - Network error IOException: Connection refused: connect
Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1463)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:344)
at $Proxy0.beginTransaction(Unknown Source)
at Main.main(Main.java:10)
Caused by: java.sql.SQLException: Network error IOException: Connection refused: connect
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:410)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
... 11 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:307)
at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:257)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:311)
... 17 more

could someone tell me that can i do?


Top
 Profile  
 
 Post subject: Re: help pls -- connection error
PostPosted: Sat May 15, 2010 11:05 am 
Newbie

Joined: Fri May 14, 2010 5:51 pm
Posts: 8
Seems to be Database connection problem.

I don't understand one thing:
Which database are you using? MySQL or SQLServer???

In the config you have:
Code:
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driber</property> (*)
<property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>


In the log:
Code:
...
15:17:44,608 INFO DriverManagerConnectionProvider:103 - [b]using driver: net.sourceforge.jtds.jdbc.Driver at URL: jdbc:jtds:sqlserver://localhost:1433/ISS[/b]
...
15:17:45,700 INFO Dialect:206 - [b]Using dialect: org.hibernate.dialect.MySQLDialect[/b]


Is there more than one configuration file in your classpath? I don't understand where these values come from.

(*) Plz make sure it is Driver and not Driber

Irshad


Top
 Profile  
 
 Post subject: Re: help pls -- connection error
PostPosted: Sat May 15, 2010 12:01 pm 
Newbie

Joined: Sat May 15, 2010 8:21 am
Posts: 4
i'm working on MySQL

i dont't have in any file this
INFO DriverManagerConnectionProvider:103 - using driver: net.sourceforge.jtds.jdbc.Driver at URL: jdbc:jtds:sqlserver://localhost:1433/ISS

and i think i' wrong

could you tell me pls where to look for it


Top
 Profile  
 
 Post subject: Re: help pls -- connection error
PostPosted: Sat May 15, 2010 12:33 pm 
Newbie

Joined: Sat May 15, 2010 8:21 am
Posts: 4
than you for your observation, i solved the problem


Top
 Profile  
 
 Post subject: Re: help pls -- connection error
PostPosted: Sat May 15, 2010 2:20 pm 
Newbie

Joined: Fri May 14, 2010 5:51 pm
Posts: 8
Is your database up and running?

Can you connect to it via commandline (>mysql)?

Plz post your directory structure.

Irshad


Top
 Profile  
 
 Post subject: Re: help pls -- connection error
PostPosted: Sat May 15, 2010 2:48 pm 
Newbie

Joined: Fri May 14, 2010 5:51 pm
Posts: 8
Good that you solved.

Plz post here what you did to solve the problem and put at your subject [SOLVED]

Irshad


Top
 Profile  
 
 Post subject: Disabling contextual LOB creation as connection was null
PostPosted: Sun Feb 17, 2013 4:56 am 
Newbie

Joined: Sun Feb 17, 2013 4:53 am
Posts: 1
<property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="connection.username">system</property>
<property name="connection.password">manager</property>

i am getting following error when i run main class

INFO: HHH000422: Disabling contextual LOB creation as connection was null
Exception in thread "main" java.lang.NullPointerException
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:207)

please help me out


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.