-----------------------------------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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" 
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- 加载属性文件 spring2.5之后的版本-->
<context:property-placeholder location="classpath:jdbc.properties"/>
<!-- 带C3P0连接池的数据源 -->
<bean id="dataSource" destroy-method="close"
class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.dirver}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>

<!-- 配置Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml"/>
<property name="dataSource"><ref bean="dataSource"/></property>
</bean>

<bean id="sccw" class="org.zkforge.petshop.controller.SccpWindow">
 <property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
 
 <bean id="cata" class="org.zkforge.petshop.model.CatalogFacade">
 <property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>

<!-- 配置spring事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>  </beans>
-----------------------hibernate配置---------------------------------------<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-configuration>    <session-factory>
        <!-- SQL dialect -->
        <!--property name="dialect">org.hibernate.dialect.HSQLDialect</property-->
        <property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.current_session_context_class">thread</property>
        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>
            
        <!-- Mapping persistence classes -->
        <mapping class="org.zkforge.petshop.model.Address"/>
        <mapping class="org.zkforge.petshop.model.Category"/>
        <mapping class="org.zkforge.petshop.model.Item"/>
        <mapping class="org.zkforge.petshop.model.Product"/>
        <mapping class="org.zkforge.petshop.model.SellerContactInfo"/>
        <mapping class="org.zkforge.petshop.model.Tag"/>
        <mapping class="org.zkforge.petshop.model.ZipLocation"/>
        <mapping class="org.zkforge.petshop.model.S_city_code_prepay"/>
    </session-factory></hibernate-configuration>

解决方案 »

  1.   

    ----------------web.xml配置-----------------------
    <?xml version="1.0" encoding="UTF-8"?><!-- web.xml
    Purpose:

    Description:

    History:
    Wed Dec 29 12:13:00     2004, Created by tomyehCopyright (C) 2004 Potix Corporation. All Rights Reserved.
    --><web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 
    <!-- spring监听 -->
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!--
    <icon>
    <small-icon></small-icon>
    <large-icon></large-icon>
    </icon>
    --> <!-- //// -->
    <!-- ZK -->
    <listener>
    <description>ZK listener for cleanup when a session is destroyed</description>
    <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
    </listener>
    <servlet>
    <description>ZK loader for ZUML pages</description>
    <servlet-name>zkLoader</servlet-name>
    <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
    <!-- Must. Specifies URI of the update engine (DHtmlUpdateServlet).
    It must be the same as <url-pattern> for the update engine.
    -->
    <init-param>
    <param-name>update-uri</param-name>
    <param-value>/zkau</param-value>
    </init-param>
    <!-- Optional. Specifies the default log level: OFF, ERROR, WARNING,
    INFO, DEBUG and FINER. If not specified, the system default is used.
    <init-param>
    <param-name>log-level</param-name>
    <param-value>OFF</param-value>
    </init-param>
    -->
    <load-on-startup>1</load-on-startup><!-- Must -->
    </servlet>
    <servlet-mapping>
    <servlet-name>zkLoader</servlet-name>
    <url-pattern>*.zul</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>zkLoader</servlet-name>
    <url-pattern>*.zhtml</url-pattern>
    </servlet-mapping> <!-- Optional. Uncomment it if you want to use richlets.
    -->
    <servlet-mapping>
    <servlet-name>zkLoader</servlet-name>
    <url-pattern>/zk/*</url-pattern>
    </servlet-mapping> <servlet>
    <description>The asynchronous update engine for ZK</description>
    <servlet-name>auEngine</servlet-name>
    <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>auEngine</servlet-name>
    <url-pattern>/zkau/*</url-pattern>
    </servlet-mapping> <!-- Uncomment if you want to use the ZK filter to post process the HTML output
    generated by other technology, such as JSP and velocity.
    <filter>
    <filter-name>zkFilter</filter-name>
    <filter-class>org.zkoss.zk.ui.http.DHtmlLayoutFilter</filter-class>
    <init-param>
    <param-name>extension</param-name>
    <param-value>html</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>zkFilter</filter-name>
    <url-pattern>/test/special.jsp</url-pattern>
    </filter-mapping>
    --> <!-- Uncomment if you want to use the inter-portlet filter to resolve
    the limitation of incapability to inter-portlet communication.
    It is useful if there are two more ZK portlets in the same portal page.
    The performance will be better if url-pattern is more specific to portal's entry
    <filter>
    <filter-name>InterPortletFilter</filter-name>
    <filter-class>org.zkoss.zk.ui.http.InterPortletFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>InterPortletFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    -->
    <!-- //// --> <!-- /////////// -->
    <!-- Miscellaneous -->
    <session-config>
    <session-timeout>120</session-timeout>
    </session-config> <!-- MIME mapping -->
    <mime-mapping>
    <extension>doc</extension>
    <mime-type>application/vnd.ms-word</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>gif</extension>
    <mime-type>image/gif</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>htm</extension>
    <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>html</extension>
    <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>jad</extension>
    <mime-type>text/vnd.sun.j2me.app-descriptor</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>jnlp</extension>
    <mime-type>application/x-java-jnlp-file</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>jpeg</extension>
    <mime-type>image/jpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>jpg</extension>
    <mime-type>image/jpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>js</extension>
    <mime-type>application/x-javascript</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>pdf</extension>
    <mime-type>application/pdf</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>png</extension>
    <mime-type>image/png</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>txt</extension>
    <mime-type>text/plain</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>xls</extension>
    <mime-type>application/vnd.ms-excel</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>xml</extension>
    <mime-type>text/xml</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>xul</extension>
    <mime-type>application/vnd.mozilla.xul-xml</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>zhtml</extension>
    <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>zip</extension>
    <mime-type>application/x-zip</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>zul</extension>
    <mime-type>text/html</mime-type>
    </mime-mapping> <welcome-file-list>
    <welcome-file>index.zul</welcome-file>
    <welcome-file>index.zhtml</welcome-file>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    </welcome-file-list><!-- 
    <resource-ref>
    <res-ref-name>jdbc/hsql</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
     -->
    </web-app>
    ----------------zk.xml文件配置---------------------
    <?xml version="1.0" encoding="UTF-8"?><!-- zk.xml
    Purpose:

    Description:

    History:
    Sun Mar 26 16:29:07     2006, Created by tomyehCopyright (C) 2006 Potix Corporation. All Rights Reserved.
    --><zk> <richlet>
    <richlet-class>org.zkoss.zkdemo.test.TestRichlet</richlet-class>
    <richlet-url>/test</richlet-url>
    </richlet> <!-- Optional -->
    <session-config>
    <timeout-uri>/timeout.zul</timeout-uri>
    </session-config> <!-- Optional -->
    <listener>
    <description>[Optional] Mointor the statistic</description>
    <listener-class>org.zkoss.zk.ui.util.Statistic</listener-class>
    </listener>

    </zk>
      

  2.   

    连不上数据库,你得看jdbc.properties这个文件啊?存放的路径是否正确,然后这个文件里面的驱动,用户名,密码是否正确!
      

  3.   

    --------jdbc.properties文件-------------
    jdbc.dirver=oracle.jdbc.driver.OracleDriver
    jdbc.url=jdbc:oracle:thin:@localhost:1521:orcl
    jdbc.username=zkl
    jdbc.password=zkl-------------截图
      

  4.   

    oracle监听是配置成127.0.0.1吗?不行你把localhost改成你机器的IP地址试试。
      

  5.   

    oracle用plsql能连接上  系统是xp 版本是oracle10g 。诡异的zk框架 头都大了 就是找不出来哪里搞错了
      

  6.   

    2011-3-30 10:35:59 org.apache.catalina.core.AprLifecycleListener init
    信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_20\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jdk1.6.0_20/bin/../jre/bin/client;C:/Program Files/Java/jdk1.6.0_20/bin/../jre/bin;C:/Program Files/Java/jdk1.6.0_20/bin/../jre/lib/i386;E:\IDE\androidIDE\android-sdk-windows-1.6_r1/tools;C:\oracle\product\10.2.0\db_1\bin;C:\Tcl\bin;C:\Program Files\Java\jdk1.6.0_20\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs;C:\Tcl\bin;C:\Program Files\Common Files\Ulead Systems\MPEG;E:\IDE\MySQL\bin;C:\Program Files\StormII\Codec;C:\Program Files\StormII
    2011-3-30 10:36:00 org.apache.coyote.http11.Http11Protocol init
    信息: Initializing Coyote HTTP/1.1 on http-8080
    2011-3-30 10:36:00 org.apache.catalina.startup.Catalina load
    信息: Initialization processed in 554 ms
    2011-3-30 10:36:00 org.apache.catalina.core.StandardService start
    信息: Starting service Catalina
    2011-3-30 10:36:00 org.apache.catalina.core.StandardEngine start
    信息: Starting Servlet Engine: Apache Tomcat/6.0.29
    2011-3-30 10:36:00 org.apache.catalina.startup.HostConfig deployDescriptor
    信息: Deploying configuration descriptor zkpetshop.xml
    2011-3-30 10:36:00 org.apache.catalina.core.ApplicationContext log
    信息: Initializing Spring root WebApplicationContext
    log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
    log4j:WARN Please initialize the log4j system properly.
    2011-3-30 10:36:03 org.zkoss.zk.ui.sys.ConfigParser parseConfigXml:148
    信息: Loading system default
    2011-3-30 10:36:04 org.zkoss.zk.ui.metainfo.DefinitionLoaders parseLang:483
    严重: Mold default for fisheyelist ignored because widget-class is required, [SYS jar:file:/E:/Work_IDE/zk_ws/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/zkpetshop/WEB-INF/lib/dojoz.jar!/metainfo/zk/lang-addon.xml line 46 col 9]
    2011-3-30 10:36:04 org.zkoss.zk.ui.metainfo.DefinitionLoaders parseLang:483
    严重: Mold default for fisheyeitem ignored because widget-class is required, [SYS jar:file:/E:/Work_IDE/zk_ws/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/zkpetshop/WEB-INF/lib/dojoz.jar!/metainfo/zk/lang-addon.xml line 54 col 9]
    2011-3-30 10:36:05 org.zkoss.zk.ui.http.WebManager <init>:111
    信息: Starting ZK 5.0.5 EE (build: 2010110316)
    2011-3-30 10:36:05 org.zkoss.zk.ui.sys.ConfigParser parse:259
    信息: Parsing jndi:/localhost/zkpetshop/WEB-INF/zk.xml
    2011-3-30 10:36:05 org.zkoss.zkex.init.WebAppInit init:29
    警告: This is an evaluation copy of ZK EE and will terminate after sixty days from the first date of installation. Should you require an open source license or commercial license for ZK EE please contact us at [email protected] for more information. Alternatively you can download ZK CE which is licensed under the LGPL.
    2011-3-30 10:36:05 org.apache.coyote.http11.Http11Protocol start
    信息: Starting Coyote HTTP/1.1 on http-8080
    2011-3-30 10:36:05 org.apache.jk.common.ChannelSocket init
    信息: JK: ajp13 listening on /0.0.0.0:8009
    2011-3-30 10:36:05 org.apache.jk.server.JkMain start
    信息: Jk running ID=0 time=0/31  config=null
    2011-3-30 10:36:05 org.apache.catalina.startup.Catalina start
    信息: Server startup in 5039 ms