static byte[] stagePeopleCode(Connection sPC_dbconn, String sPC_WhereClause) { String currentMethod = "stagePeopleCode:"; /* PeopleSoft store PeopleCode in a LONG RAW field. Each field can only hold 24000 bytes of code. If the PC is longer than that, it will be split up in multiple rows, ordered by PROGSEQ. When reading LONG RAW, SQR translates the binary data into text representing the hex values. However SQR starts choking when the data gets too big. It seemed that the only hhope I had was to deal with it in managable size chunks, however I was unable to find any Oracle / SQR tricks to return only a substring of the LONG RAW field. BLOBs were easier to work with, but I could still not find a way to translate the LONG RAW into a BLOB on the fly. My solution was to create a temp table (if it didn't already exist), and copy the LONG RAW into a BLOB field there, converting it using the to_lob Oracle function. Now I can use the dbms_lob functions to return 2000 byte chunks. */ /* Java works with byte streams so the whole thing simplified. Don't need method Build-Temp-Table, NextByte, Get-Next-Segment, HexToDec. sPC_WhereClause is: OBJECTVALUE1 = 'something', OBJECTVALUE2 = 'something', etc. */ StringBuffer sb = new StringBuffer(); /* Log: 200711-mysql Start */ //sb.append("Select PROGSEQ, PROGTXT from sysadm.pspcmprog"); sb.append("Select PROGSEQ, PROGTXT from " + class_Dbowner + ".pspcmprog"); /* Log: 200711-mysql end */ sb.append(" where upper(OBJECTVALUE1) = ? and upper(OBJECTVALUE2) = ? "); sb.append(" and upper(OBJECTVALUE3) = ? and upper(OBJECTVALUE4) = ? "); sb.append(" and upper(OBJECTVALUE5) = ? and upper(OBJECTVALUE6) = ? "); sb.append(" and upper(OBJECTVALUE7) = ? "); sb.append(" order by PROGSEQ "); String s = sb.toString(); /* Oracle begin */ // String[] OOB = new String[4000]; /* Oracle end */ /* MySQL begin */ byte[] OOB = new byte[4000]; int bytecnt = 0; String blobdata = ""; /* MySQL end */ int[] progseq = new int[100]; int row_cnt = 0; if (class_Debug) System.out.println(currentMethod + " SQL: " + s); if (class_Debug) System.out.println(currentMethod + " sPC_WhereClause: " + sPC_WhereClause); String regex = "OBJECTVALUE[1-7] = '"; String[] $ObjectValue = sPC_WhereClause.split(regex); for (int w1 = 1; w1 <= 7; w1++) { $ObjectValue[w1] = $ObjectValue[w1].substring(0,$ObjectValue[w1].indexOf("'")); } try { PreparedStatement ps = sPC_dbconn.prepareStatement(s); ps.clearParameters(); for (int w2 = 1; w2 <= 7; w2++) { ps.setString(w2, $ObjectValue[w2].toUpperCase()); } ResultSet resultset = ps.executeQuery(); for (row_cnt = 1; resultset.next(); row_cnt++) { /* Oracle begin */ // OOB[row_cnt] = resultset.getString("progtxt"); /* Oracle end */ /* MySQL begin */ Blob datablob = resultset.getBlob("progtxt"); /* Change BLOB data into a byte array. */ OOB = datablob.getBytes(1, (int) datablob.length()); //InputStream in = datablob.getBinaryStream(); //try { // bytecnt = in.read(OOB); //} catch (IOException e) { // System.out.println("IOException error" + e.getMessage()); //} //for (int k = 0; k < bytecnt; k++) { // blobdata = blobdata + (char) OOB[k]; //} /* MySQL end */ progseq[row_cnt] = resultset.getInt("progseq"); } } catch(SQLException se) { se.printStackTrace(); System.out.println(currentMethod + se.toString()); } if (class_Debug) { /* This is going to display junk. */ System.out.println(currentMethod + " Select from pspcmprog: " + OOB.toString()); /* Display the hexadecimal data as stored in the database. */ // for (int zz = 1; zz <= row_cnt; zz++) { // System.out.println(currentMethod + " Select from pspcmprog: " + OOB[zz]); // } } // if (class_Debug) System.out.println(currentMethod + " Convert from hex to decimal. "); /* Oracle begin */ /* Convert from hex to decimal. First put data into String. */ // String blobdata = ""; // for (int k = 1; k < row_cnt; k++) { // blobdata = blobdata + OOB[k]; // } /* Oracle end */ // char[] blobchar = blobdata.toCharArray(); /* String into char array. */ // if (class_Debug) System.out.println(currentMethod + " Length of progtxt from pspcmprog: " + blobdata.length()); // int length = blobdata.length(); // byte[] outData = new byte[length/2]; /* Create byte array for decodeHex output. */ // outData = decodeHex(blobchar); // return outData; return OOB; }