简体   繁体   English

"sql server 的连接地址"

[英]connection url for sql server

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>

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

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

Complete hibernate cfg property (MS SQL server) is as follows: 完整的hibernate cfg属性(MS SQL Server)如下:

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

This configuration worked for me: hibernate.cfg.xml<\/em><\/strong>这个配置对我有用<\/em>: hibernate.cfg.xml<\/em><\/strong>

<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

    <session-factory>

        <!-- JDBC Database connection settings -->
        <property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
        <property name="connection.url">jdbc:sqlserver://localhost:1433;databaseName=YOUR_DATA_BASENAME</property>
        <property name="connection.username">YOUR_USER_NAME</property>
        <property name="connection.password">YOUR_PASSWORD</property>

        <!-- JDBC connection pool settings ... using built-in test pool -->
        <property name="connection.pool_size">1</property>

        <!-- Select our SQL dialect -->
        <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>

        <!-- Echo the SQL to stdout -->
        <property name="show_sql">true</property>

        <!-- Set the current session context -->
        <property name="current_session_context_class">thread</property>

    </session-factory>

</hibernate-configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM