这是我的配置文件,但是链接不起来. <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <property name="hibernate.connection.url">jdbc:oracle:thin:@LOCALHOST:1521:ORCL</property> <property name="hibernate.connection.username">SCOTT</property> <property name="hibernate.connection.password">tiger</property> <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property> <property name="hibernate.show_sql">true</property> <property name="hibernate.hbm2ddl.auto">update</property> <mapping resource="user.hbm.xml"/> <mapping resource="friend.hbm.xml"/> <mapping resource="userinfo.hbm.xml"/> <mapping resource="offlinemessage.hbm.xml"/> </session-factory> </hibernate-configuration> 以下是报错信息 Hibernate Dialect must be explicitly set at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57) at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39) at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128) at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2090) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2086) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1311) at org.fw.utils.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:32) at org.fw.qq.server.QQServer$1.actionPerformed(QQServer.java:46) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at java.awt.Component.processMouseEvent(Component.java:6505) at javax.swing.JComponent.processMouseEvent(JComponent.java:3320) at java.awt.Component.processEvent(Component.java:6270) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:694) at java.awt.EventQueue$3.run(EventQueue.java:692) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:708) at java.awt.EventQueue$4.run(EventQueue.java:706) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:705) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) 请教正确的配置方法. |
|
40分 |
SSH中的H最主要解决的是ORM,实体和数据库里面数据的映射,连接数据库我们是写在spring里面实现的,通过依赖注入把H注入到S中,代码如下:
<!– dataSource injection–> <bean id=”DataSource” class=”org.springframework.jdbc.datasource.DriverManagerDataSource” > <property name=”driverClassName” value=”com.mysql.jdbc.Driver”/> <property name=”url” value=”jdbc:mysql://localhost:3306/tna”/> <property name=”username” value=”root”/> <property name=”password” value=”root”/> </bean> <!– sessionFactory injection–> <bean id=”SessionFactory” class=”org.springframework.orm.hibernate3.LocalSessionFactoryBean”> <property name=”dataSource” ref=”DataSource”/> <property name=”hibernateProperties”> <props> <prop key=”hibernate.dialect”>org.hibernate.dialect.DerbyDialect</prop> <prop key=”hibernate.show_sql”>true</prop> <prop key=”hibernate.format_sql”>true</prop> </props> </property> <property name=”mappingResources”> <list> <value>com/oracle/tna/domain/User.hbm.xml</value> <value>com/oracle/tna/domain/Item.hbm.xml</value> <value>com/oracle/tna/domain/Score.hbm.xml</value> <value>com/oracle/tna/domain/Admin.hbm.xml</value> <value>com/oracle/tna/domain/Userscore.hbm.xml</value> </list> </property> </bean> <!– hibernateTemplate injection–> |
60分 |
你把里面的数据库的部分改一下,我这个是mysql数据库,别的都一样
|
多谢,我找到问题了,少了一句代码,你说的这个是一个问题,多谢,。 |
|
谢谢回答 |