-->
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.  [ 4 posts ] 
Author Message
 Post subject: Connection always established with default database
PostPosted: Fri Sep 25, 2009 4:46 am 
Newbie

Joined: Fri Sep 25, 2009 2:50 am
Posts: 2
Hi everybody,

we are developing a project using Hibernate V3.3.1.GA on JBoss 5.1/SQLServer. We noticed that the application always connects to the database defined as default for the given user on the SQLServer, regardless of the database name specified in the connection uri. In other words, it behaves as if no database name is passed to the jdbc driver...

Is this a bug or the correct behaviour?

Many thanks, Enrico


Top
 Profile  
 
 Post subject: Re: Connection always established with default database
PostPosted: Fri Sep 25, 2009 10:12 am 
Beginner
Beginner

Joined: Wed Jul 09, 2008 5:34 am
Posts: 41
Location: Brno, Czech Republic
What happens if you try to connect via direct JDBC, with the same URL? Does it uses the "default" database, or the one you specified in the URL? How does the URL looks like? Are you specifying the connection parameters as hibernate properties, or via a JBoss managed DataSource?


Top
 Profile  
 
 Post subject: Re: Connection always established with default database
PostPosted: Fri Sep 25, 2009 10:42 am 
Newbie

Joined: Fri Sep 25, 2009 2:50 am
Posts: 2
jpkrohling wrote:
What happens if you try to connect via direct JDBC, with the same URL? Does it uses the "default" database, or the one you specified in the URL?

I had the same doubt and therefore wrote a little jdbc test application to verify the behaviour. The test shows that if one omits the database name the connection is effectively established with the default database, but if the database name is provided, the connection is established with the desired database. That is why I suspect that Hibernate drops the database name from the uri...

jpkrohling wrote:
How does the URL looks like? Are you specifying the connection parameters as hibernate properties, or via a JBoss managed DataSource?

The connection details are spedified in Jboss DataSource as following:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE datasources
    PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
   
<datasources>
   <local-tx-datasource>
     <jndi-name>GestioneEdiliziaPrivataDatasource</jndi-name>
     <connection-url>jdbc:sqlserver://srv002\DT_GestioneEdiliziaPrivata_Test:1433</connection-url>
     <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
     <user-name>dt_ep</user-name>
     <password>dt_ep</password>
   </local-tx-datasource>   
</datasources>

Unfortunately, on the SQLServer the dt_ep user defaults to a different database, with which the connection is established...

Thanks in advance, Enrico


Top
 Profile  
 
 Post subject: Re: Connection always established with default database
PostPosted: Fri Sep 25, 2009 11:24 am 
Beginner
Beginner

Joined: Wed Jul 09, 2008 5:34 am
Posts: 41
Location: Brno, Czech Republic
Should I assume your database name is "DT_GestioneEdiliziaPrivata_Test"? If so, try this URL instead:

jdbc:sqlserver://srv002:1433;databaseName=DT_GestioneEdiliziaPrivata_Test


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