Hibernate连接本地PostgreSQL时运行良好,并自动创建表,但当我们想要使用Azure SQL Server(Microsoft SQL Server)并更改驱动程序名称等时,我们没有收到任何错误消息,但未能正常工作(未创建表)。
jdbc.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.databaseurl=jdbc:sqlserver://xxxx.database.windows.net:1433;database=xxxx
jdbc.password=xxxx
jdbc.user=xxx@xxxx
jdbc.encrypt=true
jdbc.hostNameInCertificate=*.database.windows.net
jdbc.loginTimeout=30;
jdbc.dialect=org.hibernate.dialect.SQLServerDialect
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/jdbc.properties" >
</bean>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.databaseurl}" p:username="${jdbc.user}"
p:password="${jdbc.password}">
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan">
<list>
<value>com.xxx.entity</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.c3p0.min_size">5</prop>
<prop key="hibernate.c3p0.max_size">20</prop>
<prop key="hibernate.c3p0.idle_test_period">60</prop>
<prop key="hibernate.c3p0.max_statements">100</prop>
<!--<prop key="hibernate.hbm2ddl.auto">${database.hbm2ddl.auto}</prop>-->
<!--<prop key="hibernate.show_sql">${database.show_sql}</prop>-->
<!--<prop key="hibernate.format_sql">${database.format_sql}</prop>-->
</props>
</property>
</bean>
jdbc:sqlserver://dp-test1.database.windows.net:1433;databaseName=test1;user=admin@dp-test1;password={your_password_here};encrypt=true;trustServerCertificate=false;hostNameInCertificate=.database.windows.net;loginTimeout=30;
祝好, <br>Meet - meet-bhagdev