List of usage examples for java.rmi RemoteException RemoteException
public RemoteException(String s, Throwable cause)
From source file:org.kchine.rpf.db.DBLayer.java
public HashMap<String, PoolDataDB> getPoolDataHashMap() throws RemoteException, AccessException { HashMap<String, PoolDataDB> result = new HashMap<String, PoolDataDB>(); Statement stmt = null;/*from www . jav a2 s .c om*/ ResultSet rset = null; try { checkConnection(); stmt = _connection.createStatement(); rset = stmt.executeQuery("select POOL_NAME,POOL_PREFIXES,TIMEOUT from POOL_DATA"); while (rset.next()) { result.put(rset.getString(1), new PoolDataDB(rset.getString(1), getPrefixes(rset.getString(2)), rset.getInt(3))); } } catch (SQLException sqle) { throw new RemoteException("", (sqle)); } finally { if (rset != null) try { stmt.close(); } catch (Exception e) { throw new RemoteException("", (e)); } if (stmt != null) try { stmt.close(); } catch (Exception e) { throw new RemoteException("", (e)); } } return result; }
From source file:org.kchine.rpf.db.DBLayer.java
public void addNode(NodeDataDB nodeData) throws RemoteException { Statement stmt = null;//from w w w . j a v a 2 s .c o m try { checkConnection(); stmt = _connection.createStatement(); stmt.execute( "INSERT INTO NODE_DATA(NODE_NAME, HOST_IP,HOST_NAME,LOGIN,PWD,INSTALL_DIR,CREATE_SERVANT_COMMAND, KILL_SERVANT_COMMAND ,OS,SERVANT_NBR_MIN,SERVANT_NBR_MAX,POOL_PREFIX, PROCESS_COUNTER) values (" + "'" + nodeData.getNodeName() + "'," + "'" + nodeData.getHostIp() + "'," + "'" + nodeData.getHostName() + "'," + "'" + nodeData.getLogin() + "'," + "'" + (nodeData.getPwd().trim().equals("") ? "" : cipherPwd(nodeData.getPwd())) + "'," + "'" + nodeData.getInstallDir() + "'," + "'" + nodeData.getCreateServantCommand() + "'," + "'" + nodeData.getKillServantCommand() + "'," + "'" + nodeData.getOS() + "'," + nodeData.getServantNbrMin() + "," + nodeData.getServantNbrMax() + "," + "'" + nodeData.getPoolPrefix() + "'" + ",0" + ")"); _connection.commit(); } catch (SQLException sqle) { if (isNoConnectionError(sqle) && canReconnect()) { addNode(nodeData); } else { throw new RemoteException("", (sqle)); } } finally { if (stmt != null) try { stmt.close(); } catch (Exception e) { throw new RemoteException("", (e)); } } }
From source file:org.kchine.rpf.db.DBLayer.java
public void addPool(PoolDataDB poolData) throws RemoteException { Statement stmt = null;/*from w w w.j av a 2 s .co m*/ try { checkConnection(); String prefixes = ""; for (int i = 0; i < poolData.getPrefixes().length; ++i) prefixes += poolData.getPrefixes()[i] + (i == poolData.getPrefixes().length - 1 ? "" : ","); stmt = _connection.createStatement(); stmt.execute("INSERT INTO POOL_DATA(POOL_NAME, TIMEOUT,POOL_PREFIXES) values (" + "'" + poolData.getPoolName() + "'," + poolData.getBorrowTimeout() + "," + "'" + prefixes + "')"); _connection.commit(); } catch (SQLException sqle) { if (isNoConnectionError(sqle) && canReconnect()) { addPool(poolData); } else { throw new RemoteException("", (sqle)); } } finally { if (stmt != null) try { stmt.close(); } catch (Exception e) { throw new RemoteException("", (e)); } } }
From source file:org.kchine.rpf.db.DBLayer.java
public void updateNode(NodeDataDB nodeData) throws RemoteException { Statement stmt = null;//from ww w . j a v a2s . co m String ip = nodeData.getHostIp().trim(); String host = nodeData.getHostName().trim(); String prefix = nodeData.getPoolPrefix().trim(); String nodeName = nodeData.getNodeName(); if (ip.equals("")) { try { ip = InetAddress.getByName(nodeData.getHostName()).getHostAddress(); } catch (Exception e) { throw new RemoteException("", (e)); } } try { checkConnection(); stmt = _connection.createStatement(); String updateStr = "UPDATE NODE_DATA set " + " HOST_IP=" + "'" + ip + "'," + " HOST_NAME=" + "'" + host + "'," + " POOL_PREFIX=" + "'" + prefix + "'," + " LOGIN=" + "'" + nodeData.getLogin() + "'," + " PWD=" + "'" + (nodeData.getPwd().trim().equals("") ? "" : cipherPwd(nodeData.getPwd())) + "'," + " INSTALL_DIR=" + "'" + nodeData.getInstallDir() + "'," + " CREATE_SERVANT_COMMAND=" + "'" + nodeData.getCreateServantCommand() + "'," + " KILL_SERVANT_COMMAND=" + "'" + nodeData.getKillServantCommand() + "'," + " OS=" + "'" + nodeData.getOS() + "'," + " SERVANT_NBR_MIN=" + nodeData.getServantNbrMin() + "," + " SERVANT_NBR_MAX=" + nodeData.getServantNbrMax() + "" + " where NODE_NAME='" + nodeName + "'"; System.out.println(updateStr); stmt.execute(updateStr); _connection.commit(); } catch (SQLException sqle) { sqle.printStackTrace(); if (isNoConnectionError(sqle) && canReconnect()) { updateNode(nodeData); } else { throw new RemoteException("", (sqle)); } } finally { if (stmt != null) try { stmt.close(); } catch (Exception e) { throw new RemoteException("", (e)); } } }
From source file:org.kchine.rpf.db.DBLayer.java
public void removeNode(String nodeName) throws RemoteException { Statement stmt = null;//from w w w .j a v a2s .c o m try { checkConnection(); stmt = _connection.createStatement(); String deleteStr = "delete from NODE_DATA where NODE_NAME='" + nodeName + "'"; stmt.execute(deleteStr); _connection.commit(); } catch (SQLException sqle) { if (isNoConnectionError(sqle) && canReconnect()) { removeNode(nodeName); } else { throw new RemoteException("", (sqle)); } } finally { if (stmt != null) try { stmt.close(); } catch (Exception e) { throw new RemoteException("", (e)); } } }
From source file:org.kchine.rpf.db.DBLayer.java
public void removePool(String poolName) throws RemoteException { Statement stmt = null;//w ww .j a va 2 s . c om try { checkConnection(); stmt = _connection.createStatement(); String deleteStr = "delete from POOL_DATA where POOL_NAME='" + poolName + "'"; stmt.execute(deleteStr); _connection.commit(); } catch (SQLException sqle) { if (isNoConnectionError(sqle) && canReconnect()) { removePool(poolName); } else { throw new RemoteException("", (sqle)); } } finally { if (stmt != null) try { stmt.close(); } catch (Exception e) { throw new RemoteException("", (e)); } } }
From source file:org.kchine.rpf.db.DBLayer.java
public void updatePool(PoolDataDB poolData) throws RemoteException { Statement stmt = null;// w w w . j a v a2 s . co m String prefixes = ""; for (int i = 0; i < poolData.getPrefixes().length; ++i) prefixes += poolData.getPrefixes()[i] + (i == poolData.getPrefixes().length - 1 ? "" : ","); try { checkConnection(); stmt = _connection.createStatement(); String updateStr = "UPDATE POOL_DATA set TIMEOUT=" + poolData.getBorrowTimeout() + "," + " POOL_PREFIXES='" + prefixes + "' where POOL_NAME='" + poolData.getPoolName() + "'"; System.out.println(updateStr); stmt.execute(updateStr); _connection.commit(); } catch (SQLException sqle) { sqle.printStackTrace(); if (isNoConnectionError(sqle) && canReconnect()) { updatePool(poolData); } else { throw new RemoteException("", (sqle)); } } finally { if (stmt != null) try { stmt.close(); } catch (Exception e) { throw new RemoteException("", (e)); } } }
From source file:org.kchine.rpf.db.DBLayer.java
public void unlockServant(String servantName) throws RemoteException { Statement stmt = null;// w ww. j a va 2 s. c o m try { checkConnection(); stmt = _connection.createStatement(); stmt.execute("UPDATE SERVANTS SET IN_USE=0, PING_FAILURES=0" + ",BORROW_HOST_NAME=NULL" + ",BORROW_HOST_IP=NULL" + ",BORROW_PROCESS_ID=NULL" + ",BORROW_SESSION_INFO_HEX=NULL" + ",RETURN_TIME=" + sysdateFunctionName() + ",RETURN_HOST_NAME='" + getHostName() + "'" + ",RETURN_HOST_IP='" + getHostIp() + "'" + ",RETURN_PROCESS_ID='" + getProcessId() + "'" + " WHERE NAME='" + servantName + "'"); } catch (SQLException sqle) { if (isNoConnectionError(sqle) && canReconnect()) { unlockServant(servantName); } else { throw new RemoteException("", (sqle)); } } finally { if (stmt != null) try { stmt.close(); } catch (Exception e) { throw new RemoteException("", (e)); } } }
From source file:org.kchine.rpf.db.DBLayer.java
public Vector<HashMap<String, Object>> getTableData(String tableName, String condition) throws RemoteException { Vector<HashMap<String, Object>> result = new Vector<HashMap<String, Object>>(); Statement stmt = null;// www. j a v a 2s .c o m ResultSet rset = null; try { checkConnection(); stmt = _connection.createStatement(); rset = stmt.executeQuery("select * from " + tableName + (condition == null || condition.equals("") ? "" : " WHERE " + condition)); while (rset.next()) { HashMap<String, Object> hm = new HashMap<String, Object>(); for (int i = 1; i <= rset.getMetaData().getColumnCount(); ++i) { hm.put(rset.getMetaData().getColumnName(i), rset.getObject(i)); } result.add(hm); } } catch (SQLException sqle) { if (isNoConnectionError(sqle) && canReconnect()) { return getTableData(tableName, condition); } else { throw new RemoteException("", (sqle)); } } finally { if (rset != null) try { stmt.close(); } catch (Exception e) { throw new RemoteException("", (e)); } if (stmt != null) try { stmt.close(); } catch (Exception e) { throw new RemoteException("", (e)); } } return result; }
From source file:org.kchine.rpf.db.DBLayer.java
public void unregisterAll() throws RemoteException, NotBoundException, AccessException { if (getProcessId().equals(UNKOWN)) return;//from w w w. j a v a 2s. c o m Statement stmt = null; ResultSet rset = null; try { checkConnection(); stmt = _connection.createStatement(); lock(stmt); stmt.execute("UPDATE SERVANTS SET IN_USE=0 " + ",RETURN_TIME=" + sysdateFunctionName() + ",RETURN_HOST_NAME='" + getHostName() + "'" + ",RETURN_HOST_IP='" + getHostIp() + "'" + ",RETURN_PROCESS_ID='" + getProcessId() + "'" + " WHERE BORROW_HOST_IP='" + getHostIp() + "' AND BORROW_PROCESS_ID='" + getProcessId() + "'"); } catch (SQLException sqle) { if (isNoConnectionError(sqle) && canReconnect()) { unregisterAll(); } else { throw new RemoteException("", (sqle)); } } finally { try { if (stmt != null) { unlock(stmt); _connection.commit(); } } catch (Exception e) { throw new RemoteException("", (e)); } if (stmt != null) try { stmt.close(); } catch (Exception e) { throw new RemoteException("", (e)); } if (rset != null) try { stmt.close(); } catch (Exception e) { throw new RemoteException("", (e)); } } }