Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> java & results sets

java & results sets

From: steve <E_at_E.COM>
Date: Wed, 28 Nov 2001 05:15:45 +0800
Message-ID: <1f3kh7b.oznf6j1c0eqwwN%E@E.COM>


Hi,
I have the following code, to validate a user

that calls an oracle server side proc.
the driver is oracle 8.1.5 thin, the database is 8i 8.1.5.

the program compiles and runs, but the damned result set(myValues[0]) is returning a string of values as follows "0x4152333930544B504C4E","0x74657374","0x31323334","0x73686974"

which is actually the HEX representation of the strings ie
0x31323334 =1234

the data contained is correct , but it is a hex string!! of the values i want.
how can I correct the code or is it a bug

public static String[] Validate_user(String User,String Password){

        String Magic_key="";
        String [] Ret_results=new String[]{"-1","","",""};       
        ResultSet rset =null;
         ARRAY array1;
          Connection conn;
        OracleCallableStatement cstmt=null;
      
         // Create a statement
       // Execute the statement and query
      try
      {

// Call the function which returns a nested table
 

         String The_qry="{ ? = call oracle.external_user.valid_usr("+

"'"+User.trim()+
"','"+Password.trim()+
"','"+String.valueOf(SerialversionUID).trim()+
"')}";  


cstmt=(OracleCallableStatement)SQL_functions.dbconn.prepareCall(The_qry) ;        

cstmt.registerOutParameter(1,OracleTypes.ARRAY,"ORACLE.RETURN_VARCHAR2_0 4");

   cstmt.execute();

        // Get the return value and covert it into a JDBC ResultSet
        array1 =
(ARRAY)((OracleCallableStatement)cstmt).getOracleObject(1);
        rset=array1.getResultSet();

       // Loop through ResultSet rows    
        while(rset.next()){
        // Get the object that is in the address_list ( SQL TYPE
"ADDRESS" )
        // 1st column is the row index
        // 2nd column is the actual object

oracle.sql.STRUCT obj= (oracle.sql.STRUCT)rset.getObject(2);

  // Get the column attributes for the object

Object myValues[] = (Object[])obj.getAttributes();

         

// Object myValues=obj.getAttributes();
// get each of the object columns
// It is the programmers responsibility to know specifically
// what these types are. In this case they are all strings.
//0x4152333930544B504C4E,0x74657374,0x31323334,0x73686974
Ret_results[0]=(String)myValues[0];
Ret_results[1]=(String)myValues[1];
Ret_results[2]=(String)myValues[2];
Ret_results[3]=(String)myValues[3];


System.out.println(Ret_results[0]+","+Ret_results[1]+","+Ret_results[2]+ ","+Ret_results[3]);
// the above returns

//0x4152333930544B504C4E,0x74657374,0x31323334,0x73686974 to the system screen.

        }
                }

     catch (Exception e)
      {
      
      Error_funcs.handleError(e);
      }
        return  Ret_results;
        }       
Received on Tue Nov 27 2001 - 15:15:45 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US