web-inf/jdbc.properties文件贴出来看看。注意里面的jdbc.driverClassName把sqlserver的jar文件放到web-inf/lib目录里

解决方案 »

  1.   

    hibernate.cfg.xml文件:<?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
    <hibernate-configuration>
       
     <session-factory>
       
         <property name="connection.datasource">java:comp/env/jdbc/hellohibernate</property>
        
        <property name="show_sql">false</property>
          
      <property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>        <mapping resource="com/xanada/po/Cat.hbm.xml"/>
      
      </session-factory>
    </hibernate-configuration>
      

  2.   

    Session session = HibernateUtil.currentSession();
           /*       Transaction tx = session.beginTransaction();
             Query query = session.createQuery("select * from test");
                 
                */
                
               // query.setCharacter("sex", 'F');          /*
                for (Iterator it = query.iterate(); it.hasNext();) {
                    Cat cat = (Cat) it.next();
                    out.println("Cat: " + cat.toString() + "<br>");
                }            tx.commit();            HibernateUtil.closeSession();
                */
            } catch (HibernateException e) {
                e.printStackTrace(out);
            }      
            out.println("</body>");
            out.println("</html>");
        }
    }       从我开如注释的地方出错。
            高手指教!