论坛首页 Java企业应用论坛

十分钟在jb里面运行hibernate的简单例子。

浏览 63134 次
该帖已经被评为精华帖
作者 正文
   发表时间:2004-03-30  
为什么我换成ms-sql后就会出现这样的错误呢?
程序没有变过啊,只是jdbc改过了:(

信息: Starting Coyote HTTP/1.1 on port 8080
javax.naming.NameNotFoundException: Name hibernate_connection_factory is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:811)
at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:183)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at com.proton.util.comm.DBManager.getMsSqlConn(DBManager.java:42)
at com.proton.util.comm.DBManager.getSession(DBManager.java:28)
at com.proton.db.Map.StudentMap.findAllStudents(StudentMap.java:46)
at com.proton.action.test.testAction.perform(testAction.java:47)
at org.apache.struts.action.Action.execute(Action.java:420)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
DataBase Error
0 请登录后投票
   发表时间:2004-04-01  
- no JNDI name configured
不知错再那里。恳请帮忙!
0 请登录后投票
   发表时间:2004-04-03  
weifengaa 写道
Cannot disable AUTO_COMMIT

是因为Mysql 的版本不够高吗?

确实和jdbc驱动有关系,我使用的是官方的最新的jdbc驱动就解决了这个问题。如果使用mm的jdbc好像就有问题。
0 请登录后投票
   发表时间:2004-04-06  
谢谢楼主
已经解决了
0 请登录后投票
   发表时间:2004-04-06  
答:afengfeng
在引用第三方库文件时不要导入log4j这个包
0 请登录后投票
   发表时间:2004-04-09  
学习学习,终于搞定
0 请登录后投票
   发表时间:2004-04-18  
我用的是mysql数据库
可是编译出错如下:

D:\JBuilder9\jdk1.4\bin\javaw -classpath "E:\Projects\JB9project\hibernate_demo2\classes;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\ant-1.5.3.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\ant-optional-1.5.3.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\c3p0-0.8.3.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\cglib-2.0-rc2.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\commons-collections-2.1.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\commons-dbcp-1.1.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\commons-lang-1.0.1.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\commons-logging-1.0.3.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\commons-pool-1.1.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\concurrent-1.3.2.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\connector.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\dom4j-1.4.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\ehcache-0.6.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\jaas.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\jboss-cache.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\jboss-common.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\jboss-jmx.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\jboss-system.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\jcs-1.0-dev.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\jdbc2_0-stdext.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\jgroups-2.2.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\jta.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\junit-3.8.1.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\log4j-1.2.8.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\odmg-3.0.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\oscache-2.0.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\proxool-0.8.3.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\swarmcache-1.0rc2.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\xalan-2.4.0.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\xerces-2.4.0.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\lib\xml-apis.jar;C:\5.6\hibernate相关\hibernate\hibernate ruanjian\hibernate-2.1.2\hibernate-2.1\hibernate2.jar;D:\j2sdk1.4.0\lib\mm.mysql-2.0.4-bin.jar;D:\JBuilder9\jdk1.4\jre\lib\rt.jar;D:\JBuilder9\jdk1.4\jre\lib\i18n.jar;D:\JBuilder9\jdk1.4\jre\lib\sunrsasign.jar;D:\JBuilder9\jdk1.4\jre\lib\jsse.jar;D:\JBuilder9\jdk1.4\jre\lib\jce.jar;D:\JBuilder9\jdk1.4\jre\lib\charsets.jar;D:\JBuilder9\jdk1.4\jre\classes;D:\JBuilder9\jdk1.4\lib\tools.jar"  hello.Hello
00:19:42,781  INFO Environment:462 - Hibernate 2.1.2

00:19:42,812  INFO Environment:496 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.hibernate.cache.HashtableCacheProvider, hibernate.cache.use_query_cache=true, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, hibernate.connection.url=jdbc:mysql:///test, hibernate.connection.password=, hibernate.connection.pool_size=1}

00:19:43,265  INFO Environment:518 - using java.io streams to persist binary types

00:19:43,265  INFO Environment:519 - using CGLIB reflection optimizer

00:19:43,281  INFO Configuration:329 - Mapping resource: hello/Message.hbm.xml

00:19:44,265  INFO Binder:229 - Mapping class: hello.Message -> Messages

00:19:44,453  INFO Configuration:595 - processing one-to-many association mappings

00:19:44,453  INFO Configuration:604 - processing one-to-one association property references

00:19:44,453  INFO Configuration:629 - processing foreign key constraints

00:19:44,531  INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.MySQLDialect

00:19:44,531  INFO SettingsFactory:58 - Maximim outer join fetch depth: 1

00:19:44,546  INFO SettingsFactory:62 - Use outer join fetching: true

00:19:44,562  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)

00:19:44,562  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1

00:19:44,562 FATAL DriverManagerConnectionProvider:57 - JDBC Driver class not found: com.mysql.jdbc.Driver

net.sf.hibernate.HibernateException: JDBC Driver class not found: com.mysql.jdbc.Driver

at net.sf.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:58)

at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)

at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:64)

at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1119)

at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:748)

at hello.Hello.main(Hello.java:32)

Exception in thread "main"


==============================================================================

我在project->project properties->path->required library
以及tools->jdk->class 均指向了mm.mysql-2.0.4-bin.jar
不知为何还是找不到驱动???
请教各位帮忙!
==============================================================================


附:hibernate.properties

######################
### Query Language ###
######################

## define query language constants / function names

hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N'


#################
### Platforms ###
#################

## JNDI Datasource

#hibernate.connection.datasource jdbc/test
#hibernate.connection.username db2
#hibernate.connection.password db2


## HypersonicSQL

#hibernate.connection.driver_class org.hsqldb.jdbcDriver
#hibernate.connection.username sa
#hibernate.connection.password
#hibernate.connection.url jdbc:hsqldb:hsql://localhost
#hibernate.connection.url jdbc:hsqldb:test
#hibernate.connection.url jdbc:hsqldb:.


## PostgreSQL

#hibernate.dialect net.sf.hibernate.dialect.PostgreSQLDialect
#hibernate.connection.driver_class org.postgresql.Driver
#hibernate.connection.url jdbc:postgresql:template1
#hibernate.connection.username pg
#hibernate.connection.password
#hibernate.query.substitutions yes 'Y', no 'N'


## DB2

#hibernate.dialect net.sf.hibernate.dialect.DB2Dialect
#hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver
#hibernate.connection.url jdbc:db2:test
#hibernate.connection.username db2
#hibernate.connection.password db2


## DB2/400

#hibernate.dialect net.sf.hibernate.dialect.DB2400Dialect
#hibernate.connection.username user
#hibernate.connection.password password

## Native driver
#hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver
#hibernate.connection.url jdbc:db2://systemname

## Toolbox driver
#hibernate.connection.driver_class com.ibm.as400.access.AS400JDBCDriver
#hibernate.connection.url jdbc:as400://systemname


## MySQL

hibernate.dialect net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class org.gjt.mm.mysql.Driver
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql:///test
hibernate.connection.username root
hibernate.connection.password



## Oracle

#hibernate.dialect net.sf.hibernate.dialect.Oracle9Dialect
#hibernate.dialect net.sf.hibernate.dialect.OracleDialect
#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
#hibernate.connection.username scott
#hibernate.connection.password tiger
#hibernate.connection.url jdbc:oracle:thin:@localhost:1521:orcl


## Sybase

#hibernate.dialect net.sf.hibernate.dialect.SybaseDialect
#hibernate.connection.driver_class com.sybase.jdbc2.jdbc.SybDriver
#hibernate.connection.username sa
#hibernate.connection.password sasasa
#hibernate.connection.rl jdbc:sybase:Tds:co3061835-a:5000/tempdb


## Mckoi SQL

#hibernate.dialect net.sf.hibernate.dialect.MckoiDialect
#hibernate.connection.driver_class com.mckoi.JDBCDriver
#hibernate.connection.url jdbc:mckoi:///
#hibernate.connection.url jdbc:mckoi:local://C:/mckoi1.00/db.conf
#hibernate.connection.username admin
#hibernate.connection.password nimda


## SAP DB

#hibernate.dialect net.sf.hibernate.dialect.SAPDBDialect
#hibernate.connection.driver_class com.sap.dbtech.jdbc.DriverSapDB
#hibernate.connection.url jdbc:sapdb://localhost/TST
#hibernate.connection.username TEST
#hibernate.connection.password TEST
#hibernate.query.substitutions yes 'Y', no 'N'


## MS SQL Server

#hibernate.dialect net.sf.hibernate.dialect.SQLServerDialect
#hibernate.connection.username sa
#hibernate.connection.password sa

## JSQL Driver
#hibernate.connection.driver_class com.jnetdirect.jsql.JSQLDriver
#hibernate.connection.url jdbc:JSQLConnect://1E1/test

## JTURBO Driver
#hibernate.connection.driver_class com.newatlanta.jturbo.driver.Driver
#hibernate.connection.url jdbc:JTurbo://1E1:1433/test

## WebLogic Driver
#hibernate.connection.driver_class weblogic.jdbc.mssqlserver4.Driver
#hibernate.connection.url jdbc:weblogic:mssqlserver4:1E1:1433

## Microsoft Driver (not recommended!)
#hibernate.connection.driver_class com.microsoft.jdbc.sqlserver.SQLServerDriver
#hibernate.connection.url jdbc:microsoft:sqlserver://1E1;DatabaseName=test;SelectMethod=cursor

## jTDS (not supported!)
#hibernate.connection.driver_class net.sourceforge.jtds.jdbc.Driver
#hibernate.connection.url jdbc:jtds:sqlserver://1E1/test;SelectMethod=cursor
#hibernate.jdbc.use_scrollable_resultset false

## Interbase

#hibernate.dialect net.sf.hibernate.dialect.InterbaseDialect
#hibernate.connection.username sysdba
#hibernate.connection.password masterkey

## DO NOT specify hibernate.connection.sqlDialect

## InterClient

#hibernate.connection.driver_class interbase.interclient.Driver
#hibernate.connection.url jdbc:interbase://localhost:3060/C:/firebird/test.gdb

## Pure Java

#hibernate.connection.driver_class org.firebirdsql.jdbc.FBDriver
#hibernate.connection.url jdbc:firebirdsql:localhost/3050:/firebird/test.gdb


## Pointbase

#hibernate.dialect net.sf.hibernate.dialect.PointbaseDialect
#hibernate.connection.driver_class com.pointbase.jdbc.jdbcUniversalDriver
#hibernate.connection.url jdbc:pointbase:embedded:sample
#hibernate.connection.username PBPUBLIC
#hibernate.connection.password PBPUBLIC


#################################
### Hibernate Connection Pool ###
#################################

hibernate.connection.pool_size 1


###########################
### C3P0 Connection Pool###
###########################

#hibernate.c3p0.max_size 2
#hibernate.c3p0.min_size 2
#hibernate.c3p0.timeout 5000
#hibernate.c3p0.max_statements 100
#hibernate.c3p0.idle_test_period 3000
#hibernate.c3p0.acquire_increment 2
##hibernate.c3p0.validate false


###################################
### Apache DBCP Connection Pool ###
###################################

## connection pool

#hibernate.dbcp.maxActive 100
#hibernate.dbcp.whenExhaustedAction 1
#hibernate.dbcp.maxWait 120000
#hibernate.dbcp.maxIdle 10

## prepared statement cache

#hibernate.dbcp.ps.maxActive 100
#hibernate.dbcp.ps.whenExhaustedAction 1
#hibernate.dbcp.ps.maxWait 120000
#hibernate.dbcp.ps.maxIdle 10

## optional query to validate pooled connections:

#hibernate.dbcp.validationQuery select 1 from dual
#hibernate.dbcp.testOnBorrow true
#hibernate.dbcp.testOnReturn false


##############################
### Proxool Connection Pool###
##############################

## Properties for external configuration of Proxool

hibernate.proxool.pool_alias pool1

## Only need one of the following

#hibernate.proxool.existing_pool true
#hibernate.proxool.xml proxool.xml
#hibernate.proxool.properties proxool.properties

## Or, alternatively, all of these
## Standard configuration properties of Proxool

#hibernate.proxool.house-keeping-sleep-time 30000
#hibernate.proxool.house-keeping-test-sql
#hibernate.proxool.maximum-connection-count 4
#hibernate.proxool.maximum-connection-lifetime 4
#hibernate.proxool.simultaneous-build-throttle 2
#hibernate.proxool.maximum-active-time 500
#hibernate.proxool.minimum-connection-count 2
#hibernate.proxool.fatal-sql-exception
#hibernate.proxool.prototype-count
#hibernate.proxool.statistics
#hibernate.proxool.recently-started-threshold
#hibernate.proxool.overload-without-refusal-lifetime


#################################
### Plugin ConnectionProvider ###
#################################

## use a custom ConnectionProvider (if not set, Hibernate will choose a built-in ConnectionProvider using hueristics)

#hibernate.connection.provider_class net.sf.hibernate.connection.DriverManagerConnectionProvider
#hibernate.connection.provider_class net.sf.hibernate.connection.DatasourceConnectionProvider
#hibernate.connection.provider_class net.sf.hibernate.connection.C3P0ConnectionProvider
#hibernate.connection.provider_class net.sf.hibernate.connection.DBCPConnectionProvider
#hibernate.connection.provider_class net.sf.hibernate.connection.ProxoolConnectionProvider


#######################
### Transaction API ###
#######################

## the Transaction API abstracts application code from the underlying JTA or JDBC transactions

#hibernate.transaction.factory_class net.sf.hibernate.transaction.JTATransactionFactory
#hibernate.transaction.factory_class net.sf.hibernate.transaction.JDBCTransactionFactory


## to use JTATransactionFactory, Hibernate must be able to locate the UserTransaction in JNDI
## default is java:comp/UserTransaction
## you do NOT need this setting if you specify hibernate.transaction.manager_lookup_class

#jta.UserTransaction jta/usertransaction
#jta.UserTransaction javax.transaction.UserTransaction
#jta.UserTransaction UserTransaction


## to use JCS caching with JTA, Hibernate must be able to obtain the JTA TransactionManager

#hibernate.transaction.manager_lookup_class net.sf.hibernate.transaction.JBossTransactionManagerLookup
#hibernate.transaction.manager_lookup_class net.sf.hibernate.transaction.WeblogicTransactionManagerLookup
#hibernate.transaction.manager_lookup_class net.sf.hibernate.transaction.WebSphereTransactionManagerLookup
#hibernate.transaction.manager_lookup_class net.sf.hibernate.transaction.OrionTransactionManagerLookup
#hibernate.transaction.manager_lookup_class net.sf.hibernate.transaction.ResinTransactionManagerLookup


##############################
### Miscellaneous Settings ###
##############################

## print all generated SQL to the console

#hibernate.show_sql true


## auto schema export

#hibernate.hbm2ddl.auto create-drop
#hibernate.hbm2ddl.auto create
#hibernate.hbm2ddl.auto update


## specify a JDBC isolation level

#hibernate.connection.isolation 4


## set the JDBC fetch size

#hibernate.jdbc.fetch_size 25


## set the maximum JDBC 2 batch size (a nonzero value enables batching)

hibernate.jdbc.batch_size 0


## enable use of JDBC 2 scrollable ResultSets (specifying a Dialect will cause Hibernate to use a sensible default)

#hibernate.jdbc.use_scrollable_resultset true


## use streams when writing binary types to / from JDBC

hibernate.jdbc.use_streams_for_binary true


## use JDBC 3 PreparedStatement.getGeneratedKeys to get the identifier of an inserted row

#hibernate.jdbc.use_get_generated_keys true


## specify a default schema for unqualified tablenames

#hibernate.default_schema test


## use a custom stylesheet for XML generation (if not specified, hibernate-default.xslt will be used)

#hibernate.xml.output_stylesheet C:/Hibernate/net/sf/hibernate/hibernate-default.xslt


## enable outerjoin fetching (specifying a Dialect will cause Hibernate to use sensible default)

#hibernate.use_outer_join false


## set the maximum depth of the outer join fetch tree

hibernate.max_fetch_depth 1


## enable CGLIB reflection optimizer (enabled by default)

#hibernate.cglib.use_reflection_optimizer false


##########################
### Second-level Cache ###
##########################

## optimize chache for minimal "puts" instead of minimal "gets" (good for clustered cache)

#hibernate.cache.use_minimal_puts true


## enable the query cache

hibernate.cache.use_query_cache true


## choose a cache implementation

#hibernate.cache.provider_class net.sf.ehcache.hibernate.Provider
#hibernate.cache.provider_class net.sf.hibernate.cache.EmptyCacheProvider
hibernate.cache.provider_class net.sf.hibernate.cache.HashtableCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.TreeCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.OSCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.JCSCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.SwarmCacheProvider


############
### JNDI ###
############

## specify a JNDI name for the SessionFactory

#hibernate.session_factory_name hibernate/session_factory


## Hibernate uses JNDI to bind a name to a SessionFactory and to look up the JTA UserTransaction;
## if hibernate.jndi.* are not specified, Hibernate will use the default InitialContext() which
## is the best approach in an application server

#file system
#hibernate.jndi.class com.sun.jndi.fscontext.RefFSContextFactory
#hibernate.jndi.url file:/

#WebSphere
#hibernate.jndi.class com.ibm.websphere.naming.WsnInitialContextFactory
#hibernate.jndi.url iiop://localhost:900/
0 请登录后投票
   发表时间:2004-04-18  
上边问题已排除,是mysql驱动新版本的问题


可是又报错如下,不知哪里出错?? 和原文雷同啊
09:28:02,453  INFO QueryCache:39 - starting query cache at region: net.sf.hibernate.cache.QueryCache

09:28:02,687  WARN SessionImpl:3348 - afterTransactionCompletion() was never called

09:28:02,687  WARN SessionImpl:3358 - unclosed connection

net.sf.hibernate.HibernateException: The database returned no natively generated identity value

at net.sf.hibernate.persister.AbstractEntityPersister.getGeneratedIdentity(AbstractEntityPersister.java:1224)

at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:529)

at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)

at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)

at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:906)

at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)

at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:757)

at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:720)

at hello.Hello.main(Hello.java:43)

Exception in thread "main"
0 请登录后投票
   发表时间:2004-05-15  
wangjianan 写道
Query q = session.createQuery("from Message as message where message.id=1");

这里的sql语句什么意思,我怎么看不懂,特别是as message ???


这是hibernate中的查询语言HQL啊,as message 表示查询结果转换为message类的一个聚集。
0 请登录后投票
   发表时间:2004-05-29  
我用的是oracle817,jdbc驱动是classes12.zip该怎么加啊。为什么总是提示net.sf.hibernate.HibernateException: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver
我已在%hibernate%\lib下加入了classes12.zip文件了
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics