zoukankan      html  css  js  c++  java
  • 在Java中使用Hibernate,使用不同数据库服务名

    在使用Hibernate连接数据库时,如果使用指定的服务名,使用如下配置:

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
        <session-factory>
            <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
            <property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
            <property name="hibernate.connection.password"></property>
            <property name="hibernate.connection.url">jdbc:jtds:sqlserver://localhost:1433/TTA;INSTANCE=SQL2000</property>
            <property name="hibernate.connection.username">sa</property>
            <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
            <property name="hibernate.current_session_context_class">thread</property>
        </session-factory>
    </hibernate-configuration>
    如果不指定服务名,将"hibernate.connection.url"行改为:
    <property name="hibernate.connection.url">jdbc:jtds:sqlserver://localhost/TTA</property>
  • 相关阅读:
    Nginx
    Web 系统架构一般组成
    分布式系统常见的问题
    Scala + Thrift+ Zookeeper+Flume+Kafka配置笔记
    Spring Boot—21Actuator--监控
    Zookeeper
    Spring Boot—20Zookeeper
    Spring Boot—19Session
    Spring Boot—19Cache
    Spring Boot—18Redis
  • 原文地址:https://www.cnblogs.com/wjhx/p/2062308.html
Copyright © 2011-2022 走看看