Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

connection url for sql server

Tags:

java

hibernate

I downloaded microsfot's jdbc driver, and I am not sure what the connection.url should be?

 <property name="connection.driver_class">org.microsoft.sqlserver.jdbc</property>
 <property name="connection.url">jdbc:</property>

  ..
  <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>

i configured sqlexpress to work via tcpip and a static port already.

like image 521
mrblah Avatar asked Jan 06 '10 00:01

mrblah


2 Answers

Here you go:

      <property name = "hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
      <property name = "hibernate.connection.driver_class" value = "com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
      <property name = "hibernate.connection.url" value = "jdbc:sqlserver://localhost;databaseName=cust;instanceName=SQLEXPRESS;"/>
      <property name = "hibernate.connection.username" value = "sa"/>
      <property name = "hibernate.connection.password" value = ""/>
      <property name = "hibernate.show_sql" value="true"/>
like image 159
dcp Avatar answered Sep 22 '22 05:09

dcp


Connection strings are database dependent. You should take a look at a good reference web site.

If you're trying to connect to SQL Server from a Java application, try this:

jdbc:microsoft:sqlserver://<HOST>:<PORT>[;DatabaseName=<DB>]
com.microsoft.jdbc.sqlserver.SQLServerDriver
like image 45
Ed Altorfer Avatar answered Sep 22 '22 05:09

Ed Altorfer