Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Hibernate连接到MS SQL Server_Java_Sql Server_Hibernate_Azure_Database Connection - Fatal编程技术网

Java 使用Hibernate连接到MS SQL Server

Java 使用Hibernate连接到MS SQL Server,java,sql-server,hibernate,azure,database-connection,Java,Sql Server,Hibernate,Azure,Database Connection,我正在尝试使用Java中的Hibernate连接到SQL Server数据库。我的hibernate.cfg.xml文件如下所示: <hibernate-configuration>    <session-factory>   <property name = "hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property> <property nam

我正在尝试使用Java中的Hibernate连接到SQL Server数据库。我的hibernate.cfg.xml文件如下所示:

<hibernate-configuration>   
<session-factory>  
    <property name = "hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
    <property name = "hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
    <property name = "hibernate.connection.url">jdbc:sqlserver://*******.database.windows.net:1433;databaseName=*******;</property>
    <property name = "hibernate.connection.username">*******@******</property>
    <property name = "hibernate.connection.password">**********</property>
    <property name = "hibernate.show_sql">true</property>
</session-factory>
</hibernate-configuration>
在不使用ORM的情况下,我尝试使用以下连接字符串,但一切正常:

"jdbc:sqlserver://*******.database.windows.net:1433;" +
"database=*****;" +
"user=*****@*******;" +
"password=********;" +
"encrypt=true;" +
"trustServerCertificate=false;" +
"hostNameInCertificate=*.database.windows.net;" +
"loginTimeout=30;"
数据库位于MS Azure上。有人能帮我配置hibernate吗?
是否可以在没有配置文件的情况下使用连接字符串配置hibernate?

这通常意味着Xml中的某个地方存在非法字符。可能是相关的Thx,我重新键入了xml文件,现在它有另一个错误:)可能有一些随机字符,因为配置文件的某些部分是复制粘贴的。您提供的配置部分在我测试后没有任何问题。配置文件的其他部分可能有一些错误。你能提供更多关于你的配置文件的信息吗?
"jdbc:sqlserver://*******.database.windows.net:1433;" +
"database=*****;" +
"user=*****@*******;" +
"password=********;" +
"encrypt=true;" +
"trustServerCertificate=false;" +
"hostNameInCertificate=*.database.windows.net;" +
"loginTimeout=30;"