java - 如何为 PostgreSQL 编辑 Oracle 11G 设置
问题描述
我有一个 jar 文件,它在数据库中上传资源文件,即 Oracle 11G。我想创建一个在 PostgreSQL 中上传文件的 Jar 文件,但出现以下错误。
这是我的上下文文件:
<?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.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) 在 org.hibernate.SQLStateConverter.convert(SQLStateConverter.java:67) 执行查询.loader.Loader.doList(Loader.java:2216) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) at org.hibernate.loader.Loader.list(Loader.java:2099) at org. hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)在 sun.reflect.NativeMethodAccessorImpl 的 com.unisys.stealth.framework.services.resourceconfig.serviceobject.ResourceUploader.uploadWorkflowTemplate(ResourceUploader.java:183)。在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java: 43) 的 invoke0(Native Method) 498) 在 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。org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 中的interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)在 com.sun.proxy.$Proxy2.uploadWorkflowTemplate(Unknown Source) 在 com.unisys.stealth.framework.services.resourceconfig.serviceobject.StartUpload.main(StartUpload.java:86) 引起:org.postgresql.util.PSQLException :错误:关系“tbl_fr_workflow_config”不存在位置:org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) 的 349 ) 在 org.postgresql.core.v3.QueryExecutorImpl。在 org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) 在 org.postgresql.jdbc.PgPreparedStatement 在 org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) 执行(QueryExecutorImpl.java:308) .executeWithFlags(PgPreparedStatement.java:143) 在 org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) 在 org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:106) 在 org.hibernate.loader。 Loader.getResultSet(Loader.java:1787) at org.hibernate.loader.Loader.doQuery(Loader.java:674) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at org.hibernate.loader .Loader.doList(Loader.java:2213) ... 20 更多441) 在 org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143) 在 org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java) :106) 在 org.hibernate.loader.Loader.getResultSet(Loader.java:1787) 在 org.hibernate.loader.Loader.doQuery(Loader.doQuery) 的 org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) java:674) 在 org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) 在 org.hibernate.loader.Loader.doList(Loader.java:2213) ... 还有 20 个441) 在 org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143) 在 org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java) :106) 在 org.hibernate.loader.Loader.getResultSet(Loader.java:1787) 在 org.hibernate.loader.Loader.doQuery(Loader.doQuery) 的 org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) java:674) 在 org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) 在 org.hibernate.loader.Loader.doList(Loader.java:2213) ... 还有 20 个在 org.hibernate.loader.Loader.getResultSet(Loader.java:1787) 在 org.hibernate.loader.Loader 的 org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) 的 executeQuery(PgPreparedStatement.java:106) .doQuery(Loader.java:674) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at org.hibernate.loader.Loader.doList(Loader.java:2213) ... 还有 20 个在 org.hibernate.loader.Loader.getResultSet(Loader.java:1787) 在 org.hibernate.loader.Loader 的 org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) 的 executeQuery(PgPreparedStatement.java:106) .doQuery(Loader.java:674) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at org.hibernate.loader.Loader.doList(Loader.java:2213) ... 还有 20 个
解决方案
PostgreSQL 的 Spring XML 数据源配置
<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>
推荐阅读
- javascript - Visual Studio Code:使用 Firefox ESR 调试 JavaScript
- markdown - pandoc 中有没有办法在代码块顶部包含文件名?
- ssl - 使用 StackExchange.Redis 与 Redis 建立 SSL 连接
- c# - 无法使用证书存储中的客户端证书,只能通过从文件加载
- android - 如何通过意图直接编辑而不是副本将 PDF 传递给 Android 上的 Adobe Reader?
- c# - RSA - 数据不能长于模数错误
- html - CKAN资源表单html“描述”字段,我如何/在哪里可以将其他字段更改为与描述相同的大小?
- gatsby - 使用 gatsby 创建新项目的命令不起作用
- azure-data-explorer - 汇总来自 customMeasurements 列的值
- dart - 将数据报数据转换为字符串 HEX