日期:2014-05-17  浏览次数:20750 次

在myeclipse可以连接数据库,但是在网页上就不行了,数据库也没报错,怎么回事啊?
第一张是在类里测试的,没问题

第二章是在浏览器测试的,打开连接失败,但是myeclipse没有报错。。。

------解决方案--------------------
可能是连接oracle数据库的路径错了吧
------解决方案--------------------
驱动换个最新版的试试
------解决方案--------------------
hibernate.cfg.xml这个文件有没有?数据库和对象的映射关系文件。
------解决方案--------------------
你在hql欲查询的字段名和hbm.xml中的属性不匹配或者找不到引起的。 

------解决方案--------------------
引用:
Quote: 引用:

Quote: 引用:

hibernate.cfg.xml这个文件有没有?数据库和对象的映射关系文件。


我把它放到spring里托管了。。下面是spring的代码:
<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">


<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl">
</property>
<property name="username" value="c##accp"></property>
<property name="password" value="accp"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
</props>
</property>
</bean>

<bean id="studentDao" class="com.accp.dao.impl.StudentDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<bean id="studentService" class="com.accp.service.impl.StudentServiceImpl">
<property name="dao" ref="studentDao"/>
</bean>

<bean id="studentLoginAction" class="com.accp.action.student.LoginAction">
<property name="service" ref="studentService"></property>
</bean>
</beans>

托管?里面有映射数据库的东西?