hibernate---java.lang.UnsupportedOperationException: The user must supply a JDBC connection

在配置hibernate时,执行代码时一直抛错:

Exception in thread "main" java.lang.UnsupportedOperationException: The user must supply a JDBC connection
	at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:54)
	at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
	at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
	at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
	at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1616)
	at org.hibernate.loader.Loader.doQuery(Loader.java:717)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
	at org.hibernate.loader.Loader.loadEntity(Loader.java:1953)
	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86)
	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76)
	at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3270)
	at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)
	at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)
	at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
	at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
	at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
	at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1080)
	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:997)
	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:990)
	at com.ado.test.hibernate.HibernateTest.main(HibernateTest.java:25)

后来看了后台的源码,发现创建的ConnectionProvider实例为UserSuppliedConnectionProvider(用户自定义的Provider),配置有点异常。断点跟踪了创建该实例的代码,原来是因为在根据各个配置属性创建该实例时,因为配置属性关键字与hibernate关键字不一样,所以导致创建了用户自定义的Provider,从而出现了上面的异常。

测试代码使用的是hibernate 3.5.6,标准的关键字可以查看org.hibernate.cfg.Environment类中的定义。hibernate版本不一样,使用的关键字也不一样。这点需要注意。

hibernate 3.5.6使用的是:

hibernate.connection.driver_class
hibernate.connection.url
hibernate.connection.username
hibernate.connection.password



时间: 2024-10-28 15:51:12

hibernate---java.lang.UnsupportedOperationException: The user must supply a JDBC connection的相关文章

java.lang.UnsupportedOperationException: Not supported by BasicDataSource

场景: SpringMVC+Hibernate+Maven 问题: 在src/main/resources 目录中添加hibernate.properties文件, 则如果存在这句hibernate.hbm2ddl.auto=update 启动tomcat就报如下异常, 去掉启动不报错,访问servlet的时候报错,去掉文件中所有属性,访问也不报错hibernate.properties 文件内容:hibernate.connection.driver_class=com.mysql.jdbc.

Hbase delete遇到的常见异常: Exception in thread "main" java.lang.UnsupportedOperationException

hbase 执行批量删除时出现错误: Exception in thread "main" java.lang.UnsupportedOperationException at java.util.AbstractList.remove(AbstractList.java:161) at org.apache.hadoop.hbase.client.HTable.delete(HTable.java:852) 这种异常其实很常见,remove操作不支持,为什么会出现不支持的情况呢?检查

Android -- Canvas java.lang.UnsupportedOperationException

干货 java.lang.UnsupportedOperationException at android.view.GLES20Canvas.clipPath(GLES20Canvas.java:287) at br.com.iba.view.PageCurlView.drawCurl(PageCurlView.java:284) at br.com.iba.view.PageCurlView.onDraw(PageCurlView.java:353) at android.view.View

java.lang.UnsupportedOperationException

在使用Arrays.asList()后调用add,remove这些method时出现java.lang.UnsupportedOperationException异常.这是由于Arrays.asList() 返回java.util.Arrays$ArrayList, 而不是ArrayList.Arrays$ArrayList和ArrayList都是继承AbstractList,remove,add等method在AbstractList中是默认throw UnsupportedOperation

mybatis java.lang.UnsupportedOperationException

mybatis 的mapper配置的select查询语句,报java.lang.UnsupportedOperationException 内容如下: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.UnsupportedOpe

java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1

遇到这个bug: 末尾是解决方法.  E/AndroidRuntime: FATAL EXCEPTION: main                                                                         Process: com.XX.XX.XX, PID: 7055                                                                         java.lang.Runt

java.lang.UnsupportedOperationException:This parser does not support specification "null" version "null"

java.lang.UnsupportedOperationException: This parser does not support specification "null" version "null" at javax.xml.parsers.SAXParserFactory.setXIncludeAware(SAXParserFactory.java:448) at org.apache.commons.digester.Digester.getFact

解决错误java.lang.UnsupportedOperationException

遇到错误 Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.Android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: Java.util.concurrent.ExecutionException: java.lang.UnsupportedOperatio

java 异常java.lang.UnsupportedOperationException

在项目中采用一个枚举的集合,本人采用Collections中的空集合Collections.emptyList()在添加时发生异常: 常见集合如下: private List<VacationCategory> vacationcategorys = Collections.emptyList(); 报错误如下: -- Encapsulated exception ------------\java.lang.UnsupportedOperationException at java.util