📄 parametermapping.java
字号:
try { System.out.print(rs.getByte(1)); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } rs.close(); judge_getXXX(worked, sqleResult, 0, type); } { System.out.print(" getShort="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { System.out.print(rs.getShort(1)); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } rs.close(); judge_getXXX(worked, sqleResult, 1, type); } { System.out.print(" getInt="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { System.out.print(rs.getInt(1)); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } rs.close(); judge_getXXX(worked, sqleResult, 2, type); } { System.out.print(" getLong="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { System.out.print(rs.getLong(1)); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } rs.close(); judge_getXXX(worked, sqleResult, 3, type); } { System.out.print(" getFloat="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { System.out.print(rs.getFloat(1)); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } rs.close(); judge_getXXX(worked, sqleResult, 4, type); } { System.out.print(" getDouble="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { System.out.print(rs.getDouble(1)); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } rs.close(); judge_getXXX(worked, sqleResult, 5, type); } { System.out.print(" getBigDecimal="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { System.out.print(rs.getBigDecimal(1)); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } rs.close(); judge_getXXX(worked, sqleResult, 6, type); } { System.out.print(" getBoolean="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { System.out.print(rs.getBoolean(1)); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } rs.close(); judge_getXXX(worked, sqleResult, 7, type); } { System.out.print(" getString="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { System.out.print(rs.getString(1)); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } rs.close(); judge_getXXX(worked, sqleResult, 8, type); } { System.out.print(" getBytes="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { byte[] data = rs.getBytes(1) ; System.out.print(data == null ? null : parameterMapping.showFirstTwo(data)); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } rs.close(); judge_getXXX(worked, sqleResult, 9, type); } { System.out.print(" getDate="); boolean worked; SQLException sqleResult = null;; ResultSet rs = null; try { rs = ps.executeQuery(); rs.next(); System.out.print(rs.getDate(1)); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; // 22007 invalid date time conversion worked = "22007".equals(sqle.getSQLState()); if (worked) System.out.print(sqle.getSQLState()); } catch (Throwable t) { System.out.print(t.toString()); worked = false; } if (rs != null) rs.close(); judge_getXXX(worked, sqleResult, 10, type); } { boolean worked; SQLException sqleResult = null;; ResultSet rs = null; try { System.out.print(" getTime="); rs = ps.executeQuery(); rs.next(); System.out.print(rs.getTime(1)); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; // 22007 invalid date time conversion worked = "22007".equals(sqle.getSQLState()); if (worked) System.out.print(sqle.getSQLState()); } catch (Throwable t) { System.out.print(t.toString()); worked = false; } if (rs != null) rs.close(); judge_getXXX(worked, sqleResult, 11, type); } { boolean worked; SQLException sqleResult = null;; ResultSet rs = null; try { System.out.print(" getTimestamp="); rs = ps.executeQuery(); rs.next(); System.out.print(rs.getTimestamp(1)); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; // 22007 invalid date time conversion worked = "22007".equals(sqle.getSQLState()); if (worked) System.out.print(sqle.getSQLState()); } catch (Throwable t) { System.out.print(t.toString()); worked = false; } if (rs != null) rs.close(); judge_getXXX(worked, sqleResult, 12, type); } { System.out.print(" getAsciiStream="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { InputStream is = rs.getAsciiStream(1); // if the value is NULL speific checks are performed below. if (!isNull || B6[13][type]) { System.out.print(is == null ? "null" : parameterMapping.showFirstTwo(is)); System.out.print(" was null " + rs.wasNull()); } worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } // getAsciiStream on a NULL value for an invalid conversion // is handled differently in JCC to Cloudscape. On a non-NULL // value an exception is correctly raised by both JCC and CS. // here we check this specific case to reduce canon differences // between CNS and CS. boolean judge = B6[13][type] || specificCheck(rs, worked, sqleResult, isNull); rs.close(); if (judge) judge_getXXX(worked, sqleResult, 13, type); } { System.out.print(" getBinaryStream="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { InputStream is = rs.getBinaryStream(1); if (!isNull || B6[14][type]) { System.out.print(is == null ? "null" : parameterMapping.showFirstTwo(is)); System.out.print(" was null " + rs.wasNull()); } worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } boolean judge = B6[14][type] || specificCheck(rs, worked, sqleResult, isNull); rs.close(); if (judge) judge_getXXX(worked, sqleResult, 14, type); } { System.out.print(" getCharacterStream="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { Reader r = rs.getCharacterStream(1); if (!isNull || B6[15][type]) { System.out.print(r == null ? "null" : parameterMapping.showFirstTwo(r)); System.out.print(" was null " + rs.wasNull()); } worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } boolean judge = B6[15][type] || specificCheck(rs, worked, sqleResult, isNull); rs.close(); if (judge) judge_getXXX(worked, sqleResult, 15, type); } { System.out.print(" getClob="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { Clob clob = rs.getClob(1); if (!isNull || B6[16][type]) { System.out.print(clob == null ? "null" : clob.getSubString(1, 10)); System.out.print(" was null " + rs.wasNull()); } worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } boolean judge = B6[16][type] || specificCheck(rs, worked, sqleResult, isNull); rs.close(); if (judge) judge_getXXX(worked, sqleResult, 16, type); } { System.out.print(" getBlob="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { Blob blob = rs.getBlob(1); if (!isNull || B6[17][type]) { System.out.print(blob == null ? "null" : parameterMapping.showFirstTwo(blob.getBinaryStream())); System.out.print(" was null " + rs.wasNull()); } worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } boolean judge = B6[17][type] || specificCheck(rs, worked, sqleResult, isNull); rs.close(); if (judge) judge_getXXX(worked, sqleResult, 17, type); } { System.out.print(" getUnicodeStream="); ResultSet rs = ps.executeQuery(); rs.next(); boolean worked; SQLException sqleResult = null;; try { InputStream is = rs.getUnicodeStream(1); System.out.print(is == null ? "null" : "data"); System.out.print(" was null " + rs.wasNull()); worked = true; } catch (SQLException sqle) { sqleResult = sqle; worked = false; } rs.close(); judge_getXXX(worked, sqleResult, 18, type); } // Check to see getObject returns the correct type { System.out.print(" getObject="); ResultSet rs = ps.executeQuery(); rs.next(); SQLException sqleResult = null;; try { Object o = rs.getObject(1); Class cgo = B3_GET_OBJECT[type]; String cname; if (cgo.equals(byte[].class)) cname = "byte[]"; else cname = cgo.getName(); String msg; if (o == null) { msg = "null"; } else if (cgo.isInstance(o)) { msg = "CORRECT :" + cgo.getName(); } else { msg = "FAIL NOT :" + cgo.getName() + " is " + o.getClass().getName(); } System.out.print(msg); System.out.println(" was null " + rs.wasNull()); } catch (SQLException sqle) { sqleResult = sqle; } rs.close(); } } private static boolean specificCheck(ResultSet rs, boolean worked, SQLException sqleResult, boolean isNull) throws SQLException { boolean judge = true; if (worked && isNull && rs.wasNull()) { // JCC returns NULL if (isDB2jNet) judge = false; } else if (!worked && isNull) { if (!isDB2jNet && "22005".equals(sqleResult.getSQLState())) judge = false; } if (!judge) System.out.println("SPECIFIC CHECK OK"); return judge; } private static void judge_getXXX(boolean worked, SQLException sqleResult, int whichCall, int type) { String msg; if (worked && B6[whichCall][type]) msg = " JDBC MATCH(OK)"; else if (worked) msg = " CLOUD EXT (OK)"; else if (B6[whichCall][type]) { if (sqleResult != null) showException(sqleResult); msg = " JDBC FAIL " + SQLTypes[type]; } else { String sqlState = sqleResult.getSQLState(); if ("22005".equals(sqlState)) System.out.print("IC"); // embedded invalid conversion error else if (sqlState == null) { // embedded invalid conversion error if (sqleResult.getMessage().indexOf("Wrong result column type for requested conversion") != -1) System.out.print("IC"); else if (sqleResult != null) showException(sqleResult); } else if (sqleResult != null) showException(sqleResult); msg = " JDBC MATCH (INVALID)"; } System.out.println(msg); } private static void judge_setXXX(boolean worked, SQLException sqleResult, int whichCall, int type) { String msg; if (worked && B2_MOD[whichCall][type]) msg = " JDBC MATCH(OK)"; else if (worked)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -