求教h2数据库表找不到的问题

lysmx 2007-03-06
我用包里带的sql语句建表和记录出现下列问题,不知道什么原因,求教:
============ org.ecside.easyda.SqlUtil ============
select count(userid) from PUBLIC.USER_INFO
where 1=1
#{IF:USERNAME<>EMPTY} and username like #{USERNAME} #{/IF}
#{IF:PASSWD<>EMPTY} and passwd=#{PASSWD} #{/IF}
#{IF:USERROLE<>EMPTY} and userrole=#{USERROLE} #{/IF}
#{IF:GENDER<>EMPTY} and gender=#{GENDER} #{/IF}
select count(userid) from PUBLIC.USER_INFO
where 1=1




============ org.ecside.easyda.SqlUtil ============
org.h2.jdbc.JdbcSQLException: Table USER_INFO not found; SQL statement: select count(userid) from PUBLIC.USER_INFO
where 1=1
fins 2007-03-06
PUBLIC.USER_INFO ??
USER_INFO不是PUBLIC的啊
你不用在sql语句里指定用户的
lysmx 2007-03-06
谢谢版主的回复,我把public去掉了,还是报错:
我用包里带的sql语句建表和记录,运行程序时出现下列问题,不知道什么原因,求教:
============ org.ecside.easyda.SqlUtil ============
select count(userid) from USER_INFO
where 1=1
#{IF:USERNAME<>EMPTY} and username like #{USERNAME} #{/IF}
#{IF:PASSWD<>EMPTY} and passwd=#{PASSWD} #{/IF}
#{IF:USERROLE<>EMPTY} and userrole=#{USERROLE} #{/IF}
#{IF:GENDER<>EMPTY} and gender=#{GENDER} #{/IF}
select count(userid) from USER_INFO
where 1=1

============ org.ecside.easyda.SqlUtil ============
org.h2.jdbc.JdbcSQLException: Table USER_INFO not found; SQL statement: select count(userid) from USER_INFO
where 1=1

我的bean配置文件:
<bean id="test_datasource" class="org.ecside.common.H2DriverManagerDataSource" lazy-init="default" autowire="default" dependency-check="default">
  <property name="driverClassName" value="org.h2.Driver" />
<property name="url">
  <value>jdbc:h2:aaa</value>
  </property>
  <property name="username" value="sa" />
  <property name="password" value="" />
  <property name="autoReset" value="true" />
<property name="defaultDB">
  <value>test</value>
  </property>
  </bean>
fins 2007-03-07
哦 问题在配制文件那里

建议你还是先用默认的配制吧

<bean id="test_datasource" class="org.ecside.common.H2DriverManagerDataSource">
<property name="driverClassName" value="org.h2.Driver" />
<property name="url">
<value>jdbc:h2:file:{root}db/testdb</value>
</property>
<property name="username" value="sa" />
<property name="password" value="" />
<property name="autoReset" value="true" />
<property name="defaultDB" >
<value>{root}db/default/testdb</value>
</property>
</bean>

或者吧 autoReset defaultDB都去掉

lysmx 2007-03-07
我把配制文件修改后,重新编译启动服务器出现下列错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myEasyDA' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'test_datasource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'test_datasource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.h2.jdbc.JdbcSQLException: General error: java.lang.Error: rowcount remaining=-1 [HY000-41]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'test_datasource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.h2.jdbc.JdbcSQLException: General error: java.lang.Error: rowcount remaining=-1 [HY000-41]
Caused by: org.h2.jdbc.JdbcSQLException: General error: java.lang.Error: rowcount remaining=-1 [HY000-41]

h2数据库用的默认配置登陆建表:
Driver Class:org.h2.Driver
JDBC URL:jdbc:h2:test
fins 2007-03-07
现在 我的那个DEMO 在你机器上是完全能跑起来的吧?

只是你修改后就不行了???

你现在是想跑demo呢 还是想跑自己的应用?

你把你的完整的 applicationContext.xml 发来看看呗
spreadgossip 2007-03-12
fins 写道
哦 问题在配制文件那里

建议你还是先用默认的配制吧

<bean id="test_datasource" class="org.ecside.common.H2DriverManagerDataSource">
<property name="driverClassName" value="org.h2.Driver" />
<property name="url">
<value>jdbc:h2:file:{root}db/testdb</value>
</property>
<property name="username" value="sa" />
<property name="password" value="" />
<property name="autoReset" value="true" />
<property name="defaultDB" >
<value>{root}db/default/testdb</value>
</property>
</bean>

或者吧 autoReset defaultDB都去掉



我就是使用了这个默认配置,可是他说我链接不上。
Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.Socket.connect(Socket.java:516)
at java.net.Socket.connect(Socket.java:466)
at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:365)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:477)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:214)
at sun.net.www.http.HttpClient.New(HttpClient.java:287)
at sun.net.www.http.HttpClient.New(HttpClient.java:299)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:796)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:748)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:673)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:917)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:222)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:173)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:148)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:129)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:145)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:126)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:89)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:262)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:139)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:252)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3763)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4211)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:904)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
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:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)

Global site tag (gtag.js) - Google Analytics