问题描述
今天做了个springmvc和hibernate整合的小例子,启动tomcat会发警告,但是功能可以正常使用,报错信息如下,希望各位大神帮忙解决下:警告:Couldnotobtainconnectionmetadatajava.sql.SQLException:不支持的特性atoracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)atoracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)atoracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)atoracle.jdbc.dbaccess.DBError.throwUnsupportedFeatureSqlException(DBError.java:689)atoracle.jdbc.OracleDatabaseMetaData.supportsGetGeneratedKeys(OracleDatabaseMetaData.java:4180)atorg.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:124)atorg.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)atorg.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)atorg.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)atorg.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:860)atorg.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:779)atorg.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)atorg.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)atorg.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)atjava.util.concurrent.FutureTask.run(FutureTask.java:262)atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)atjava.lang.Thread.run(Thread.java:744)
解决方案
解决方案二:
SQL语法错误或者是数据库表的字段类型与hibernate的实体类定义的字段类型不匹配之类的
解决方案三:
字段类型不匹配这个没有看出来,实体类:publicclassUser{privateStringid;privateStringname;publicStringgetId(){returnid;}publicvoidsetId(Stringid){this.id=id;}publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name;}}映射文件<?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEhibernate-mappingPUBLIC"-//Hibernate/HibernateMappingDTD3.0//EN""http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mappingpackage="com.towery.test.pojo"><classname="User"table="tb_user"><idname="id"type="string"/><propertyname="name"type="string"/></class></hibernate-mapping>
解决方案四:
你检查下自己的数据库链接有没有问题。。看看配置文件。
解决方案五:
引用2楼guoguo1989313的回复:
字段类型不匹配这个没有看出来,实体类:publicclassUser{privateStringid;privateStringname;publicStringgetId(){returnid;}publicvoidsetId(Stringid){this.id=id;}publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name;}}映射文件<?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEhibernate-mappingPUBLIC"-//Hibernate/HibernateMappingDTD3.0//EN""http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mappingpackage="com.towery.test.pojo"><classname="User"table="tb_user"><idname="id"type="string"/><propertyname="name"type="string"/></class></hibernate-mapping>
在你的映射文件中<idname="id"type="string"/>这行下边加入一行<generatorclass="increment"></generator>或者<!generatorclass="identity"></generator>设置主键编辑方式