user1685632
user1685632

Reputation: 117

Hibernate connects to wrong database

    <property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:jtds:sqlserver://host/:port/db_name;instance=smth</property>
    <property name="hibernate.connection.username">XXX</property>
    <property name="hibernate.connection.password">YYY</property>
    <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>

With this configuration, hibernate connects my program to "master" database instead of "db_name". How can i solve this problem?

EDIT: jtds 1.2.5.

Upvotes: 3

Views: 1647

Answers (2)

user1685632
user1685632

Reputation: 117

Problem is solved - SQL Server was configured in a way that we can't use name instances. jdbc:jtds:sqlserver://host:port/db_name (without ;instance=smth) is working correctly

Upvotes: 2

duffymo
duffymo

Reputation: 308813

Your URL doesn't look right to me. I don't know if it's a typo, but it should look like this:

jdbc:jtds:sqlserver://host:port/db_name;instance=smth

You should not have a slash between host and port.

http://jtds.sourceforge.net/faq.html#urlFormat

Upvotes: 1

Related Questions