-->
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.  [ 3 posts ] 
Author Message
 Post subject: Using custom server port other than default port fails
PostPosted: Wed Oct 06, 2010 11:50 am 
Newbie

Joined: Wed Oct 06, 2010 11:34 am
Posts: 2
Hi!

I am using MySQL and I want to set a port other than 3306 in the hibernate.connection.url property, like this
Code:
<property name="hibernate.connection.url">jdbc:mysql://192.168.10.54:3308/people</property>


I know the port is open and the server accepting my user account because I can connect to the database outside from hibernate (mysqladmin, MySQL Query Browser ...)

At runtime, when hibernate creates the c3po connection pool, a dead lock appears :
Code:
2010-10-06 17:43:53,310 [Timer-2] WARN  com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@30b601 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
2010-10-06 17:43:53,323 [Timer-2] WARN  com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@30b601 -- APPARENT DEADLOCK!!! Complete Status:
   Managed Threads: 3 ...


It looks like Hibernate is trying, no matter what the specified port is, to connect to :3306. If I start my server on :3306 (but let :3308 in the connection string), create an empty database and run my code, it works (the dead lock disappears) because hibernate says that the requested table doesn't exist on that schema (obviously because the created database is empty).

Thanks for your help.


Top
 Profile  
 
 Post subject: Re: Using custom server port other than default port fails
PostPosted: Wed Oct 06, 2010 4:56 pm 
Beginner
Beginner

Joined: Fri Mar 11, 2005 7:46 am
Posts: 29
Have a look in the c3p0 code.


Top
 Profile  
 
 Post subject: Re: Using custom server port other than default port fails
PostPosted: Thu Oct 07, 2010 8:21 am 
Newbie

Joined: Wed Oct 06, 2010 11:34 am
Posts: 2
kostaky, thanks for your reply.
I don't think it comes from c3po, because a simple piece of code without c3p0 doesn't run either.
Code:
Configuration cfg = new Configuration()
      .addResource("Customer.hbm.xml")
      .setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect")
      .setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver")
      .setProperty("hibernate.connection.url", "jdbc:mysql://192.168.10.52:3308/people")
      .setProperty("hibernate.connection.username", "login")
      .setProperty("hibernate.connection.password", "password");
     
      SessionFactory sessionFactory = cfg.buildSessionFactory();
      Session session = sessionFactory.openSession();

      Transaction tx = session.beginTransaction();
      Query q = session.createQuery("select count(*) from Customer");
      long result = (Long) q.uniqueResult();
     
      tx.rollback();

The same problem happens, the server port is purely ignored ...

Thrown exception:
Code:
2010-10-07 14:22:53,471 [main] WARN  org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 08S01
2010-10-07 14:22:53,471 [main] ERROR org.hibernate.util.JDBCExceptionReporter - Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cannot open connection


If I set autoconnect=true, the previous deadlock appears. But the server is running and listenig on 3308, I can access it from other softwares.


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