gpt4 book ai didi

mysql - bluemix 服务器在 MySQL 中给出 SQLGrammarException

转载 作者:行者123 更新时间:2023-11-29 12:01:24 24 4
gpt4 key购买 nike

![out put from cf logs app-name --recent] 1我在基于后端的应用程序中开发了 spring/hibernate-MySQL。我已经在本地机器上成功测试了该应用程序。但是当我将应用程序上传到IBM bluemix时,当我访问service-->Dao方法时,到处都出现异常。它说 org.hibernate.exception.SQLGrammarException 声明类似于“SELECT 命令被拒绝给用户'username@75.126.83.16'。有趣的是,当我放置一个没有 Hibernate/spring Dao 的普通 JSP 但使用相同的连接字符串时,它可以工作.

Here is the spring-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:component-scan base-package="pojos" />
<bean id="adminService" class="pojos.AdminService">
<property name="adminDao" ref="adminDao" />
</bean>
.. Other Service class bean's info....
<bean id="adminDao" class="pojos.AdminDao">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="fieldOfficerDao" class="pojos.FieldOfficerDao">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="questionMasterDao" class="pojos.QuestionMasterDao">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
.. Other Dao class bean's info....
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>pojos/Admin.hbm.xml </value>
... And other hbm files...

</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
</props>
</property>
</bean>

<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://192.155.247.251:3307/<DB-Name>" />
<property name="username" value="<DB-User-Name>" />
<property name="password" value="<DB-Password>" />


</bean>

<bean id="dbUtil"
class="pojos.DbUtil"
init-method="initialize">
<property name="dataSource" ref="dataSource" />
</bean>

最佳答案

我刚刚从每个 .hbm.xml 文件的类标记中删除了目录属性。该属性是可选的,它包含 MySQL 的架构名称。以前是这样的

<class name="pojos.Admin" table="admin" catalog="merca">

但现在是

<class name="pojos.Admin" table="admin">

关于mysql - bluemix 服务器在 MySQL 中给出 SQLGrammarException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32308594/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com