title: Using Hibernate to connect to MS SQL Server
body: <p>I'm trying to connect to an SQL Server database using Hibernate in Java. My hibernate.cfg.xml file looks like this:</p>
  
  <pre><code>&lt;hibernate-configuration&gt;   
  &lt;session-factory&gt;  
      &lt;property name = "hibernate.dialect"&gt;org.hibernate.dialect.SQLServerDialect&lt;/property&gt;
      &lt;property name = "hibernate.connection.driver_class"&gt;com.microsoft.sqlserver.jdbc.SQLServerDriver&lt;/property&gt;
      &lt;property name = "hibernate.connection.url"&gt;jdbc:sqlserver://*******.database.windows.net:1433;databaseName=*******;&lt;/property&gt;
      &lt;property name = "hibernate.connection.username"&gt;*******@******&lt;/property&gt;
      &lt;property name = "hibernate.connection.password"&gt;**********&lt;/property&gt;
      &lt;property name = "hibernate.show_sql"&gt;true&lt;/property&gt;
  &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>After trying to run the app, I get the following error:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 9 and column 23 in RESOURCE hibernate.cfg.xml. Message: cvc-complex-type.2.3: Element 'session-factory' cannot have character [children], because the type's content type is element-only.
  </code></pre>
  
  <p>Without using an ORM, I tried using the following connection string, and everything worked just fine:</p>
  
  <pre><code>"jdbc:sqlserver://*******.database.windows.net:1433;" +
  "database=*****;" +
  "user=*****@*******;" +
  "password=********;" +
  "encrypt=true;" +
  "trustServerCertificate=false;" +
  "hostNameInCertificate=*.database.windows.net;" +
  "loginTimeout=30;"
  </code></pre>
  
  <p>The database is on MS Azure. Could someone help me with hibernate configuration?
  Is it possible to configure hibernate using a connection string, without the configuration file?</p>