我尝试使用MySQL将项目设置从SQL Server重建为Apache 2。 我刚接触JDBC,无法弄清楚所有方面。
我根据本教程安装了MySQL / JDBC Driver Setting Up MySQL/JDBC Driver on Ubuntu
将此.jar
文件添加到项目后,测试运行完美。
hibernate.cfg.xml
的内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- /MYPC:1433/Blog;instance=SQLEXPRESS local connection properties -->
<property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<!--<property name="hibernate.connection.url">jdbc:jtds:sqlserver://streamer2005.softserveinc.com/_055_OMS;instance=tc;</property>-->
<property name="hibernate.connection.url">jdbc:jtds:mysql://nazar_art/_056_DB;instance=MYSQL;</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">nazarsql</property>
<!--<property name="hibernate.hbm2ddl.auto">create</property>-->
<!-- <property name="show_sql">true</property> <property name="format_sql">true</property> -->
<mapping class="com.softserveinc.edu.oms.domain.entities.Role" />
<mapping class="com.softserveinc.edu.oms.domain.entities.Region" />
<mapping class="com.softserveinc.edu.oms.domain.entities.CustomerType" />
<mapping class="com.softserveinc.edu.oms.domain.entities.User" />
<mapping class="com.softserveinc.edu.oms.domain.entities.OrderStatus" />
<mapping class="com.softserveinc.edu.oms.domain.entities.Order" />
<mapping class="com.softserveinc.edu.oms.domain.entities.Product" />
<mapping class="com.softserveinc.edu.oms.domain.entities.Dimension" />
<mapping class="com.softserveinc.edu.oms.domain.entities.OrderItem" />
<mapping class="com.softserveinc.edu.oms.domain.entities.CreditCardType" />
</session-factory>
</hibernate-configuration>
但是当我从maven运行它失败时,这不能正常工作 如何解决这个问题?
答案 0 :(得分:0)
您使用的是Sql server还是MySql?。如果是MySql,则将方言类型更改为MySQLDialect
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>