Java语言 - java.sql.SQLException:ORA-06550

时间:2014-02-28 04:06:34

标签: java jdbc primefaces glassfish

美好的一天!

我正在使用JSF 2.1 Primefaces 3.5 Glassfish 3.2.1

public class UserListProvider extends DBConnectionPool{

    private List sortList;
    private String whereClause;
    private List fieldList;

private void getUserList() {
        List userList = new ArrayList();
        UserBean users = null;
        ResultSetMetaData rsmd = null;

        try {
            super.initializeConnection();
            conn.setAutoCommit(false);
            String sortString = createSortStmt();
            super.cs = super.conn.prepareCall("{call ROCWEB.USERLIST_DATAPROV(?,?,?)}");
            super.cs.setString(1, whereClause);
            super.cs.setString(2, sortString);
            super.cs.registerOutParameter(3, OracleTypes.CURSOR);
            super.cs.execute();

            super.rs = (ResultSet) super.cs.getObject(3);

            //getting the columns
            rsmd = super.rs.getMetaData();
            setFieldList(new ArrayList());
            for (int i = 0; i < rsmd.getColumnCount(); i++) {
                getFieldList().add(rsmd.getColumnLabel(i + 1));
            }

            while (super.rs.next()) {
                users = new UserBean();
                users.setFirstName(rs.getString("firstname"));
                users.setLastName(rs.getString("lastname"));
                users.setPassword(rs.getString("password"));
                users.setEmail(rs.getString("email"));
                users.setUsername(rs.getString("username"));
                users.setUsername(rs.getString("username"));
                users.setUserId(rs.getLong("user_id"));
                userList.add(users);
                users = null;
            }
            conn.commit();
        } catch (Exception ex) {
            ex.printStackTrace();
            try {
                if (conn != null) {
                    conn.rollback();
                }
            } catch (SQLException sqle) {
                System.out.println(sqle.getMessage());
            }
        } finally {
            super.closeAll();
        }
        if (userList.isEmpty()) {
            userList.add(new UserBean());
        }
        this.setList(userList);
    }
}
public class DBConnectionPool extends BasePageBean {

public Connection conn;
public ResultSet rs;
public PreparedStatement ps;
public CallableStatement cs;
private String whereClause = "";
private String sortClause = "";
        public void initializeConnection() {
                    try {
                        Context jdbcContext = new InitialContext();
                        DataSource ds = ((DataSource) jdbcContext.lookup("jdbc/rocjndi"));
                        DataSource dsCOP = ((DataSource) jdbcContext.lookup("jdbc/COP"));
                        if(this.conn != null){
                            this.closeAll();
                        }
                        this.conn = null;
                        this.conn = ds.getConnection();
                        this.conn =dsCOP.getConnection();
                        this.conn.setAutoCommit(false);
                    } catch (Exception e) {
                        e.printStackTrace();
                        System.out.println(this.getClass() + " - " + e.toString());
                    }
                }

}

使用上面的方法(initializeConnection)使用glassfish应用服务器连接到数据库时。我在下面得到了这个错误。如果我使用一个数据源它正在工作,但我需要两个数据源。在initializeConnection方法中使用两个DataSource时,UserListProvider类会产生以下错误。

  

栈跟踪;

SEVERE: java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00201: identifier 'ROCWEB.USERLIST_DATAPROV' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
    at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:215)
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:954)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3390)
    at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4223)
    at com.sun.gjc.spi.base.PreparedStatementWrapper.execute(PreparedStatementWrapper.java:508)
    at roc.dao.impl.UserListProvider.getUserList(UserListProvider.java:58)
    at roc.dao.impl.UserListProvider.<init>(UserListProvider.java:33)
    at roc.Login.<init>(Login.java:41)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:357)
    at java.lang.Class.newInstance(Class.java:310)
    at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:188)
    at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:102)
    at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
    at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
    at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
    at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
    at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:103)
    at com.sun.el.parser.AstValue.getTarget(AstValue.java:149)
    at com.sun.el.parser.AstValue.getType(AstValue.java:84)
    at com.sun.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:200)
    at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
    at org.primefaces.renderkit.InputRenderer.findImplicitConverter(InputRenderer.java:170)
    at org.primefaces.renderkit.InputRenderer.findConverter(InputRenderer.java:190)
    at org.primefaces.renderkit.InputRenderer.getConvertedValue(InputRenderer.java:196)
    at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
    at javax.faces.component.UIInput.validate(UIInput.java:960)
    at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
    at javax.faces.component.UIInput.processValidators(UIInput.java:698)
    at javax.faces.component.UIForm.processValidators(UIForm.java:253)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
    at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172)
    at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at roc.tools.auth.MySecurityFilter.doFilter(MySecurityFilter.java:66)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)

Please help me to solve this. 



Thank you and More Power!

1 个答案:

答案 0 :(得分:0)

我会说问题就在这里:

                   this.conn = ds.getConnection();
                   this.conn =dsCOP.getConnection();

在这两行之后,字段this.conn包含'COP'数据库连接。 ds.getConnection()返回的与'ROC'数据库的连接已丢失。

我可以理解你想要使用两个数据源,但你不能将它们分配到同一个字段!您需要创建两个单独的字段,每个字段对应一个连接,并将连接分配给不同的字段。例如:

                   this.connROC = ds.getConnection();
                   this.connCOP = dsCOP.getConnection();

我从错误消息中可以清楚地看到,您现在已经添加了使用“COP”连接来对“ROC”数据库运行查询。不出所料,这失败了,因为'COP'数据库中不存在ROCWEB包。