List of usage examples for java.lang NoSuchFieldException printStackTrace
public void printStackTrace(PrintStream s)
From source file:org.sc.probro.data.DBObject.java
public DBObject(JSONObject obj) throws SQLException { Iterator<String> keys = obj.keys(); while (keys.hasNext()) { String key = keys.next(); try {// w w w. ja v a 2 s.c om Field f = getClass().getField(key); int mod = f.getModifiers(); Class type = f.getType(); if (Modifier.isPublic(mod) && !Modifier.isStatic(mod)) { if (isSubclass(type, String.class)) { f.set(this, obj.getString(key)); } else if (isSubclass(type, Integer.class)) { f.set(this, obj.getInt(key)); } else if (isSubclass(type, Double.class)) { f.set(this, obj.getDouble(key)); } else { f.set(this, obj.get(key)); } } } catch (NoSuchFieldException e) { e.printStackTrace(System.err); } catch (IllegalAccessException e) { e.printStackTrace(System.err); } catch (JSONException e) { e.printStackTrace(System.err); } } }
From source file:org.sc.probro.data.DBObject.java
public void setFromResultSet(ResultSet rs) throws SQLException { ResultSetMetaData data = rs.getMetaData(); for (int i = 1; i <= data.getColumnCount(); i++) { String columnName = data.getColumnName(i).toLowerCase(); try {// ww w . ja va2 s . com Field f = getClass().getField(columnName); int mod = f.getModifiers(); if (Modifier.isPublic(mod) && !Modifier.isStatic(mod)) { Object value = rs.getObject(i); if (value instanceof Clob) { Clob clob = (Clob) value; f.set(this, readClob(clob)); } else if (value instanceof java.sql.Date) { java.sql.Date sqlDate = (java.sql.Date) value; long time = sqlDate.getTime(); java.util.Date date = new java.util.Date(time); f.set(this, date); } else { f.set(this, value); } } } catch (NoSuchFieldException e) { // do nothing. } catch (IllegalAccessException e) { e.printStackTrace(System.err); } } }
From source file:hudson.plugins.sshslaves.SSHLauncher.java
/** * If the SSH connection as a whole is lost, report that information. *//*from w w w . ja v a 2 s . co m*/ private boolean reportTransportLoss(Connection c, TaskListener listener) { // TODO: switch to Connection.getReasonClosedCause() post build217-jenkins-8 // in the mean time, rely on reflection to get to the object TransportManager tm = null; try { Field f = Connection.class.getDeclaredField("tm"); f.setAccessible(true); tm = (TransportManager) f.get(c); } catch (NoSuchFieldException e) { e.printStackTrace(listener.error("Failed to get to TransportManager")); } catch (IllegalAccessException e) { e.printStackTrace(listener.error("Failed to get to TransportManager")); } if (tm == null) { listener.error("Couldn't get to TransportManager."); return false; } Throwable cause = tm.getReasonClosedCause(); if (cause != null) { cause.printStackTrace(listener.error("Socket connection to SSH server was lost")); } return cause != null; }