java - 在 Spring Boot 应用程序中出现新数据库错误
问题描述
我有一个带有 SQL 服务器数据库的 Java 应用程序。它工作正常。现在我们想将数据库迁移到一个新的数据库,我得到了一个新的服务器名称、端口、实例名称以及连接数据库所需的一切。
连接成功,尝试通过应用程序执行某些查询时,出现以下错误。
org.springframework.dao.InvalidDataAccessResourceUsageException:无法提取结果集;SQL [不适用];嵌套异常是 org.hibernate.exception.SQLGrammarException: could not extract ResultSet at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:238)
客户不希望任何代码更改。指向以前的数据库或新迁移的开发环境的数据库再次正常工作。问题仅与此数据库有关。
我正在做选择操作。下面是模型类
@Entity(name = "EIDPAT")
public class UserAuthenticate {
@Id
@Column(name="UserPin")
private String userPin;
@Column(name="FirstName")
private String firstName;
@Column(name="MiddleName")
private String middleName;
@Column(name="LastName")
private String lastName;
@Column(name="Email")
private String emailAddress;
}
回购类
public interface UserAuthenticateRepository extends
CrudRepository<UserAuthenticate, String> { }
服务等级
public UserAuthenticate findUser(String userPin) {
return userAuthenticateRepository.findOne(userPin);
}
aad 数据库配置.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="SqlCon"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:jboss/jdbc/PAT/pat_ds"/>
</bean>
<bean id="jdbcTemplate"
class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="SqlCon"></property>
</bean>
<bean id="namedParameterTemplate"
class="org.springframework.jdbc.core.
namedparam.NamedParameterJdbcTemplate">
<constructor-arg ref="SqlCon"></constructor-arg>
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.
LocalContainerEntityManagerFactoryBean
">
<property name="dataSource" ref="SqlCon"></property>
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
>
</bean>
</property>
<property name="packagesToScan" value="com.mmm.aad.model">
</property>
<property name="jpaProperties">
<props>
<prop
key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
</beans>
解决方案
推荐阅读
- java - 尝试并捕获 InputMismatchException 处理。我想创建可以用控制台玩的井字游戏
- python - 将字符串写入 CSV 文件
- amazon-web-services - 使用带有 Terraform 挑战的 Powershell 为 AWS EC2 创建 EC2 用户数据
- xamarin.android - 使用屏幕旋转xamarin android处理textview的宽度
- c# - 我的 raycast 在 Unity 3D 中没有激活我的敌人死亡
- unity3d - Unity 的 Google In-App Review 插件错误:java.lang.ClassNotFoundException: com.google.android.play.core.review.ReviewManagerFactory
- thymeleaf - 为什么我在 Thymeleaf 中的锚标记没有重定向到本地文件
- reactjs - 无法输入材料ui文本字段(反应)
- arrays - 快速查找数组中的所有字符串都大于长度 4
- android - 在 Android Studio 中扩展颜色背景