Ultimatelly,I solved my problem. My work is switch my application from mysql to sqlserver database . At the very start,I forgot start sqlserver service,so the error "refused connect" always appear,(so stupid error).Next,ther error "Hibernate operation: could not execute query; uncategorized SQLException for SQL [select user0_.ID as ID, user0_.USERNAME as USERNAME0_, user0_.PASSWORD as PASSWORD0_ from user user0_]; SQL state [S1000]; error code [156]; 在关键字 'user' 附近有语法错误。; nested exception is java.sql.SQLException: 在关键字 'user' 附近有语法错误." comes out , the problem scratchs my head over .this moring i got one friend's help and eventually found the "user" should not be used as a table name,because "user" is a key in sqlserver.
Below is work I have done : (Note: my env is eclipse+myeclipse)
First:modify applicationContext.xml:
From:
1.<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/test</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>whl</value>
</property>
</bean>
2. <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
To:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>net.sourceforge.jtds.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:jtds:sqlserver://localhost:1433/test</value>
</property>
<property name="username">
<value>sa</value>
</property>
<property name="password">
<value>mssqlsys</value>
</property>
</bean>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
Second: import the sqlserver driver:jtds-1.1.jar
posted on 2006-04-11 12:41
freefly 阅读(349)
评论(0) 编辑 收藏 所属分类:
Hibernate