DB2的:
- < bean id="dataSource"
- class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- < property name="driverClassName"
- value="com.ibm.db2.jcc.DB2Driver">
- < /property>
- < property name="url"
- value="jdbc:db2://localhost:50000/MyDB">
- < /property>
- < property name="username" value="sp">< /property>
- < property name="password" value="spspsp">< /property>
- < /bean>
- < bean id="sessionFactory"
- class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- < property name="dataSource">
- < ref bean="dataSource" />
- < /property>
- < property name="hibernateProperties">
- < props>
- < prop key="hibernate.dialect">
- org.hibernate.dialect.DB2Dialect
- < /prop>
- < prop key="hibernate.show_sql">true< /prop>
- < /props>
- < /property>
sql2005 的: SQL2000也差不多.
- < bean id="dataSource"
- class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- < property name="driverClassName"
- value="net.sourceforge.jtds.jdbc.Driver">
- < /property>
- < property name="url"
- value="jdbc:jtds:sqlserver://192.168.1.64:1435">
- < /property>
- < property name="username" value="sp">< /property>
- < property name="password" value="sp">< /property>
- < /bean>
- < bean id="sessionFactory"
- class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- < property name="dataSource">
- < ref bean="dataSource" />
- < /property>
- < property name="hibernateProperties">
- < props>
- < prop key="hibernate.dialect">
- org.hibernate.dialect.SQLServerDialect
- < /prop>
- < prop key="hibernate.show_sql">true< /prop>
- < /props>
- < /property>
MySQL: 5和6的差不多的.
- < bean id="dataSource"
- class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- < property name="driverClassName"
- value="com.mysql.jdbc.Driver">
- < /property>
- < property name="url"
- value="jdbc:mysql://localhost:3306/DBNAME?useUnicode=true&characterEncoding=gbk">
- < /property>
- < property name="username" value="root">< /property>
- < property name="password" value="">< /property>
- < /bean>
- < bean id="sessionFactory"
- class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- < property name="dataSource">
- < ref bean="dataSource" />
- < /property>
- < property name="hibernateProperties">
- < props>
- < prop key="hibernate.dialect">
- org.hibernate.dialect.MySQLDialect
- < /prop>
- < prop key="hibernate.show_sql">true< /prop>
- < /props>
以上就是三大数据库的Hibernate方言。DB2的比较强悍,强制密码,并且6位以上.否则不用.
【编辑推荐】