java web项目,启动报错,could not complete schema update

发布于 2021-11-18 15:55:54 字数 9388 浏览 778 评论 7

java web 项目 框架是:hibernatet,Tapestry,Spring 数据库开始用的sqlserver2000,现在换做Access!

applicationContext_cfg.xml 配置文件
<!--定义与数据库相关的数据源  -->
	<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
		<property name="driverClassName" value="sun.jdbc.odbc.JdbcOdbcDriver" />
		<property name="url" value="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=e:/stu.mdb" />
		 <property name="username" value=""></property>
         <property name="password" value=""></property>
         <property name="maxActive" value="100"></property>
         <property name="maxIdle"  value="30"></property>
         <property name="maxWait" value="500"></property>
         <property name="defaultAutoCommit" value="true"></property>         
	</bean>
	<!--定义与数据库相关的数据源  -
			<property name="url" value="jdbc:access:///e:/stu.mdb" />
	
	<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
		<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
		<property name="url" value="jdbc:jtds:sqlserver://127.0.0.1:1433;DatabaseName=edu" />
		<property name="username" value="test" />
		<property name="password" value="test" />
	</bean>
	-->
    <!--将数据源注入到会话工厂的dataSource属性中  -->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		
		<!-- 设置自动扫描pojo所在的包 -->
		 <property name="mappingResources">

		 		<list>
				<!-- <value>hbm/Student.hbm.xml</value>
				<value>hbm/Clss.hbm.xml</value>				
				<value>hbm/TESTABCD.hbm.xml</value>	 -->
				<value>hbm/BJB.hbm.xml</value>	
				<value>hbm/GGXXB.hbm.xml</value>	
				<value>hbm/GLYB.hbm.xml</value>	
				<value>hbm/JSB.hbm.xml</value>	
				<value>hbm/LDXSB.hbm.xml</value>	
				<value>hbm/MBDAB.hbm.xml</value>	
				<value>hbm/MMWTB.hbm.xml</value>	
				<value>hbm/XSB.hbm.xml</value>	
				<value>hbm/XZJGB.hbm.xml</value>	
				<value>hbm/YXB.hbm.xml</value>	
				<value>hbm/YZB.hbm.xml</value>	
				<value>hbm/DSB.hbm.xml</value>	
				<!-- value>
					classpath*:/hbm/*.hbm.xml
				</value> -->			
		</list>	
		</property>		
		<property name="hibernateProperties">
			<!--<props>
				<prop key="hibernate.dialect">
					${hibernate.dialect}
				</prop>
				<prop key="show_sql">${hibernate.show_sql}</prop>
			</props>					
		   -->
		<value>
		    hibernate.dialect=org.hibernate.dialect.SQLServerDialect
	        hibernate.hbm2ddl.auto=update
	        hibernate.show_sql=true
	        hibernate.format_sql=false
		</value>
		</property>	
	</bean>
	<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">	
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>

启动程序所报的错误:

2012-11-12 15:34:47,683 [SchemaUpdate] [INFO] fetching database metadata
2012-11-12 15:34:47,696 [SchemaUpdate] [INFO] updating schema
2012-11-12 15:34:47,712 [JDBCExceptionReporter] [WARN] SQL Error: 0, SQLState: null
2012-11-12 15:34:47,712 [JDBCExceptionReporter] [ERROR] No data found
2012-11-12 15:34:47,716 [SchemaUpdate] [ERROR] could not complete schema update
org.hibernate.exception.GenericJDBCException: could not get table metadata: BJB
	at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
	at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(DatabaseMetadata.java:128)
	at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:995)
	at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:187)
	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:356)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
	at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4172)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4671)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041)
	at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
	at org.apache.catalina.core.StandardService.start(StandardService.java:525)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:701)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.sql.SQLException: No data found
	at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7138)
	at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3907)
	at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5698)
	at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:354)
	at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:411)
	at org.hibernate.tool.hbm2ddl.TableMetadata.<init>(TableMetadata.java:57)
	at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(DatabaseMetadata.java:113)
	... 48 more

 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

筱武穆 2021-11-25 00:36:02

是不是你的主分区空间快满了啊?

岁吢 2021-11-24 21:24:41

为什么我先用create不报错启动了一下,而后换成update就有报原来的错误了呢?

看透却不说透 2021-11-24 20:45:20

你的某个实体映射文件配置的实体结构可能跟数据库表里面的实际结构不一致。而hibernate.hbm2ddl.auto=update,意思是若有以上情况出现则自动更新数据库的表结构,这个异常意思是无法更新数据库模式。你试着先找出哪里不一
致,然后手动更新试试看。

只为守护你 2021-11-24 12:49:18

嗯,确实不报错了,纠结半天了呵呵

温柔少女心 2021-11-24 07:38:33

hibernate.hbm2ddl.auto=create

左岸枫 2021-11-24 02:50:37

我试试

初见你 2021-11-22 06:18:43

hibernate.hbm2ddl.auto=create

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文