English 中文(简体)
从Oracle那里收回价值,从Java开出的记录
原标题:Query returning values from Oracle and no records when run from Java

在我管理S.A.S.S.S.S.和Java JDBC公司关系中的任何价值没有回来的同一询问中,该记录正在与Min Creats Pers_ID一起归还。

您能否提供帮助?

select PERS_ID,CODE,BEG_DTE 
from PRD_HIST H 
where PERS_ID= 12345 
and CODE= ABC 
and CRTE_TSTP=(
  select MIN(CRTE_TSTP) 
  from PRD_HIST S 
  where H.PERS_ID=S.PERS_ID 
  and PERS_ID= 12345  
  and EFCT_END_DTE is null
)

Java

 public  static List<String[]> getPersonwithMinCreateTSTP(final String PERS_ID,final String Category,final Connection connection){
    final List<String[]> personRecords = new ArrayList<String[]>();
    ResultSet resultSet = null;
    Statement statement = null;
    String PersID=null;
    String ReportCode=null;
    String effBegDate=null;

    try{
    statement = connection.createStatement();
    final String query="select PERS_ID,CODE,EFCT_BEG_DTE from PRD_HIST H where PERS_ID= "+PERS_ID+" and CODE= "+Category+" and CRTE_TSTP=(select MIN(CRTE_TSTP) from PRD_HIST S where H.PERS_ID=S.PERS_ID and PERS_ID= "+PERS_ID+"  and EFCT_END_DTE is null)";

if (!statement.execute(query)) {
          //print error
        }
        resultSet = statement.getResultSet();
    while (resultSet.next()) {
    PersID=resultSet.getString("PERS_ID");
    ReportCode=resultSet.getString("CODE");
    effBegDate=resultSet.getString("EFCT_BEG_DTE");
    final String[] personDetails={PersID,ReportCode,effBegDate};
            personRecords.add(personDetails);
        }


    } catch (SQLException sqle) {
        CTLoggerUtil.logError(sqle.getMessage());
    }finally{ // Finally is added to close the connection and resultset
        try {
            if (resultSet!=null) {
                resultSet.close();
            }if (statement!=null) {
                statement.close();
            }
        } catch (SQLException e) {
                    //print error
        }
    }
        return personRecords;
}
问题回答

摘自您的“java方案”的“SélectT”声明,将其编成“SQ+”,并看到情况。 你们可能不会再把你们的变数确定在你们看来。 事实上,如果你在不执行选举声明的情况下印刷选举声明的话,你可能会看到错误——在需要高位的情况下降低案件价值等等。

如果你仍然能够看到,将实际问题从你们的java法典中删除。

我来到这里时遇到同样的问题——我只想把我的解决方法放在后面——我 had在我(通过plus加)插入我之后,跑“麻省理工学院”!

The database table has records but the JDBC client can t retrieve the records. Means the JDBC client doesn t have the select privileges. Please run the below query on command line:

grant  all on emp to hr;




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

热门标签