Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 739
user1685632 Avatar asked Mar 24 '26 06:03

user1685632


2 Answers

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

like image 92
user1685632 Avatar answered Mar 26 '26 18:03

user1685632


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

like image 37
duffymo Avatar answered Mar 26 '26 18:03

duffymo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!