我有一个jar文件,该文件将资源文件上传到数据库中,即Oracle 11G。我想创建一个Jar文件,该文件在PostgreSQL中上传文件,但是出现以下错误。
这是我的上下文文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>org.postgresql.Driver</value></property>
<property name="url"><value>jdbc:postgresql://localhost:5432/DBNAME</value></property>
<property name="username"><value>NAEM</value></property>
<property name="password"><value>Ulol</value></property>
</bean>
<bean id="sessionFactoryExt" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="lobHandler" ref="defaultLobHandler"></property>
<property name="mappingResources">
<list>
<value>
file1.hbm.xml
</value>
<value>file2.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.PostgreSQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.connection.release_mode">
auto
</prop>
</props>
</property>
</bean>
<bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" />
<bean id="ResourceUploader" class="com.proj.ResourceUploader" scope="prototype">
<property name="locationFolder" value="my folder local"></property>
<!-- properties for module jars movement -->
<property name="modulesReleaseFolder" value="my folder local"></property>
<property name="jbossRootFolder" value="my folder local"></property>
<property name="sourceTargetFolder">
<map> <entry key="artifacts" value="com/proj/main"></entry>
<entry key="runtime" value="com/proj/main"></entry>
<entry key="lsb" value="com/proj/main"></entry>
<entry key="thirdparty-artifacts" value="com/proj/main"></entry>
</map> </property>
<property name="moduleBackUpRequired" value="true"></property>
<property name="excemptedResourceTypes">
<list>
<value>Cert</value>
</list>
</property>
<property name="sessionFactory" ref="sessionFactoryExt"></property>
<property name="resource">
<map>
<entry>*LOTS OF ENTRIES (RESOURCE FILEs)*</entry>
</map>
</property>
<property name="wflow">
<list>....</list>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref bean="sessionFactoryExt"/></property>
</bean>
<aop:config>
<aop:pointcut id="resourceUploader"
expression="execution(* com.ResourceUploader.*(..))" />
<aop:advisor pointcut-ref="resourceUploader"
advice-ref="defaultTxAdvice" />
</aop:config>
<tx:advice id="defaultTxAdvice">
<tx:attributes>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
</beans>
错误:
org.hibernate.exception.SQLGrammarException:无法执行查询 在 org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67) 在 org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) 在org.hibernate.loader.Loader.doList(Loader.java:2216)处 org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)在 org.hibernate.loader.Loader.list(Loader.java:2099)位于 org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94) 在org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)处 org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)位于 com.unisys.stealth.framework.services.resourceconfig.serviceobject.ResourceUploader.uploadWorkflowTemplate(ResourceUploader.java:183) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:498)在 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) 在 org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 在 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 在 org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) 在 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 在 org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) 在 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 在 org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) 在com.sun.proxy。$ Proxy2.uploadWorkflowTemplate(未知来源)处 com.unisys.stealth.framework.services.resourceconfig.serviceobject.StartUpload.main(StartUpload.java:86) 引起原因:org.postgresql.util.PSQLException:错误:关系 “ tbl_fr_workflow_config”不存在位置:349,位于 org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) 在 org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) 在 org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) 在 org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) 在org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)处 org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143) 在 org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:106) 在 org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) 在org.hibernate.loader.Loader.getResultSet(Loader.java:1787)处 org.hibernate.loader.Loader.doQuery(Loader.java:674)在 org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) org.hibernate.loader.Loader.doList(Loader.java:2213)...另外20个
答案 0 :(得分:0)
PostgreSQL的Spring XML Datasourse配置
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd">
<context:component-scan base-package="com.example.*" />
<tx:annotation-driven/>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql://localhost:5432/dbname" />
<property name="username" value="postgres" />
<property name="password" value="" />
<property name="connectionProperties">
<props>
<prop key="socketTimeout">10</prop>
</props>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="annotatedClasses">
<list>
<value>com.example.model.ExampleClass</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"
p:sessionFactory-ref="sessionFactory">
</bean>
</beans>