Java sql server的连接url

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2010166/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 02:27:25  来源:igfitidea点击:

connection url for sql server

javahibernate

提问by mrblah

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

我下载了microsfot的jdbc驱动,不知道connection.url应该是什么?

 <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.

我已经将 sqlexpress 配置为通过 tcpip 和静态端口工作。

采纳答案by dcp

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"/>

回答by Ed Altorfer

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:

如果您尝试从 Java 应用程序连接到 SQL Server,请尝试以下操作:

jdbc:microsoft:sqlserver://<HOST>:<PORT>[;DatabaseName=<DB>]
com.microsoft.jdbc.sqlserver.SQLServerDriver

回答by TechSingh

Complete hibernate cfg property (MS SQL server) is as follows:

完整的hibernate cfg属性(MS SQL服务器)如​​下:

com.microsoft.sqlserver.jdbc.SQLServerDriver jdbc:sqlserver://localhost:1433;databaseName=jbpm_shared_services dbo

com.microsoft.sqlserver.jdbc.SQLServerDriver jdbc:sqlserver://localhost:1433;databaseName=jbpm_shared_services dbo

<property name="hibernate.connection.username">demoid</property>
<property name="hibernate.connection.password">March2017</property>

<property name="hibernate.hbm2ddl.auto">create</property>

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

<property name="show_sql">true</property>

<mapping class="com.knook.model.DocumentConfig"/>
<mapping class="com.knook.model.DocumentDetail"/>

If the database is someother, then you can change the hibernate.dialect, hibernate.connection.url and hibernate.connection.driver_class

如果数据库是其他人,那么您可以更改 hibernate.dialect、hibernate.connection.url 和 hibernate.connection.driver_class

values for hibernate.hbm2ddl.auto can be auto, create, update, none

hibernate.hbm2ddl.auto 的值可以是 auto、create、update、none