有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何编辑PostgreSQL的Oracle 11G设置

我有一个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: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.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) at com.unisys.stealth.framework.services.resourceconfig.serviceobject.ResourceUploader.uploadWorkflowTemplate(ResourceUploader.java:183) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at com.sun.proxy.$Proxy2.uploadWorkflowTemplate(Unknown Source) at com.unisys.stealth.framework.services.resourceconfig.serviceobject.StartUpload.main(StartUpload.java:86) Caused by: org.postgresql.util.PSQLException: ERROR: relation "tbl_fr_workflow_config" does not exist Position: 349 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143) at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:106) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) at 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 more


共 (1) 个答案

  1. # 1 楼答案

    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>