这是我的配置,没有连接池!
<hibernate-configuration>
<session-factory name="eheshnew">
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@10.50.100.42:1521:orcl</property>
<property name="connection.username">ehesh_test</property>
<property name="connection.password">ehesh_test</property>
<mapping resource="com/eheshnew/dto/UserInfo.hbm.xml"/>
</session-factory>
</hibernate-configuration>
谢谢楼上的!
<hibernate-configuration>
<session-factory name="eheshnew">
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@10.50.100.42:1521:orcl</property>
<property name="connection.username">ehesh_test</property>
<property name="connection.password">ehesh_test</property>
<mapping resource="com/eheshnew/dto/UserInfo.hbm.xml"/>
</session-factory>
</hibernate-configuration>
谢谢楼上的!
代码new Configuration().configure().buildSessionFactory();是指读入默认名为hibernate.cfg.xml的配置文件。
2006-02-10 10:25:23,609 [main] [DTDEntityResolver] [DEBUG] - trying to locate http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath under org/hibernate/
2006-02-10 10:25:23,609 [main] [DTDEntityResolver] [DEBUG] - found http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath
2006-02-10 10:25:23,671 [main] [Configuration] [DEBUG] - show_sql=true
2006-02-10 10:25:23,671 [main] [Configuration] [DEBUG] - dialect=org.hibernate.dialect.OracleDialect
2006-02-10 10:25:23,671 [main] [Configuration] [DEBUG] - connection.driver_class=oracle.jdbc.driver.OracleDriver
2006-02-10 10:25:23,671 [main] [Configuration] [DEBUG] - connection.url=jdbc:oracle:thin:@10.50.100.42:1521:orcl
2006-02-10 10:25:23,671 [main] [Configuration] [DEBUG] - connection.username=ehesh_test
2006-02-10 10:25:23,671 [main] [Configuration] [DEBUG] - connection.password=ehesh_test
2006-02-10 10:25:23,671 [main] [Configuration] [INFO] - Configured SessionFactory: eheshnew
把
<session-factory name="eheshnew">
改成
<session-factory >
name="xxxx" 是为了把SessionFactory的唯一实例bind到jndi上的,这样可以通过new InitialContext().lookup("xxxx")来得到SessionFactory,不过实际上没什么用处。
非j2ee容器下直接执行或容器不支持jndi动态bind(如tomcat)都会出现这个问题。
<session-factory name="eheshnew"><!-- 以/jndi/name绑定到JNDI的SessionFactory实例 -->去掉name
<session-factory>