gpt4 book ai didi

java - 用户必须提供 JDBC 连接

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:12:50 25 4
gpt4 key购买 nike

我有一个 DispatcherServlet.xml 文件,它的 hibernate 文件配置为

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>com/dibya/hbm/resource/model.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.username">root</prop>
<prop key="hibernate.password"></prop>
<prop key="hibernate.url">jdbc:mysql://localhost/test</prop>
<prop key="hibernate.driver_class">com.mysql.jdbc.Driver</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
</props>
</property>
</bean>

<bean id = "hibernateTemplate" class = "org.springframework.orm.hibernate3.HibernateTemplate">
<property name = "persister">
<ref bean = "sessionFactory"/>
</property>
</bean>

在我的 Controller 中,我有

@RequestMapping(value = "Hello.htm")
public String HelloWorld(Model model) {
boolean is = persister.isAllowCreate();

Person person = new Person();
person.setName("dibya");
persister.saveOrUpdate(person);

System.out.println("This is called"+is);
return "HelloWorld";
}

我收到此错误消息:

HTTP Status 500 - Request processing failed; nested exception is java.lang.UnsupportedOperationException: The user must supply a JDBC connection

请告诉我我忘了添加什么。

最佳答案

您的 hibernate 配置文件使用了错误的参数名称。正确的参数名称如下:

hibernate.connection.driver_class
hibernate.connection.url
hibernate.connection.username
hibernate.connection.password
hibernate.dialect
hibernate.show_sql

更正您的参数名称并重试。

编辑:有关参数名称的详细列表,请参阅此链接:http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html

关于java - 用户必须提供 JDBC 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25097596/

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