我下载了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>
我已经将sqlexpress配置为通过tcpip和静态端口工作。
答案 0 :(得分:12)
你走了:
<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"/>
答案 1 :(得分:2)
连接字符串取决于数据库。你应该看一下好的reference web site。
如果您尝试从Java应用程序连接到SQL Server,请尝试以下操作:
jdbc:microsoft:sqlserver://<HOST>:<PORT>[;DatabaseName=<DB>]
com.microsoft.jdbc.sqlserver.SQLServerDriver
答案 2 :(得分:0)
完整的hibernate cfg属性(MS SQL服务器)如下:
com.microsoft.sqlserver.jdbc.SQLServerDriver JDBC:SQLSERVER://本地主机: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"/>
如果数据库是另一个,那么你可以改变hibernate.dialect,hibernate.connection.url和hibernate.connection.driver_class
hibernate.hbm2ddl.auto的值可以是auto,create,update,none