0

I've been trying to connect with database in Eclipse using Hibernate. When my database is Postgresql all is ok, and I have a problem with MicrosoftSQL2008.

My server name is: .\SQLEXPRESSR2, login: admin password: admin name of db: hibernatedb and here there is my hibernate code:

<hibernate-configuration> 
    <session-factory> 
        <!-- Database connection settings -->  
    <property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
        <property name="connection.url">jdbc:sqlserver://.\SQLEXPRESSR2:1433/hibernatedb</property>
        <property name="connection.username">admin</property>
        <property name="connection.password">admin</property>

        <!-- JDBC connection pool (use the built in) --> 
        <property name="connection.pool_size">1</property>

        <!-- SQL dialect - generate SQL for a particular database -->
        <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>

        <!-- Disposable the second-level cache -->
        <property name="catch.provider_class">org.hibernate.cache.NoCacheProvider</property>

        <!-- Echo all executed SQL statements -->
        <property name="show_sql">true</property>

        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">create</property>

        <!-- Names the annotated entity class-->
        <mapping class="org.szefu.Workers"/>        

    </session-factory>

 </hibernate-configuration>

My TCP Port I changed for: 1433 (IP ALL) (it was 0 default in SQL Server Configuration Manager).

Thanks for any ideas

szefu
  • 551
  • 1
  • 5
  • 11

3 Answers3

0

org.hibernate.dialect.SQLServer2008Dialect please specify this as your dialect and check for other properties too. I think you are specifying wrong values for properties.

Also check for driver url as I don't know why you are using this weird way.

Ajay Bhojak
  • 1,161
  • 9
  • 17
0

try jdbc:sqlserver://{computername/address}\\SQLEXPRESSR2:1433;databaseName=hibernatedb

you are still using postgresql connection url syntax.
Check other sqlserver connection URL properties if you need (like integratedSecurity=true).
If you are connecting to remote machine enable tcp-it like described here

Community
  • 1
  • 1
Luca Basso Ricci
  • 17,829
  • 2
  • 47
  • 69
0

Thanks a lot!

Change the name of hibernate dialect was sufficient and I changed also database syntax for: ;databaseName=hibernatedb

szefu
  • 551
  • 1
  • 5
  • 11