private boolean login(String[] part) { ResultSet rs = null; try { rs = beanOracle.selection("PASSWORD", "UTILISATEURS", "LOGIN = '******'"); } catch (SQLException e) { System.err.println(e.getStackTrace()); } String pwd = null; try { if (!rs.next()) { SendMsg("ERR#Login invalide"); } else pwd = rs.getString("PASSWORD"); } catch (SQLException ex) { System.err.println(ex.getStackTrace()); } if (pwd.equals(part[2])) { SendMsg("ACK"); return true; } else SendMsg("ERR#Mot de passe incorrecte"); return false; }
private void inputLorryWithoutReserv(String[] request) { ResultSet rs = null; String[] idList = request[2].split("@"); try { rs = beanOracle.selection("X, Y", "PARC", "ETAT=0"); } catch (SQLException ex) { SendMsg("ERR#Base de donnée inaccessible"); System.err.println("Erreur SQL exception input lorry" + ex.getStackTrace()); return; } String reponse = "ACK#"; ArrayList emplacement = new ArrayList(); try // on regarde si y'a assez de place et on recupere l'id de ces places. { for (int i = 0; i < idList.length; i++) { if (rs.next()) { reponse = reponse + idList[i] + "==>(" + rs.getString("X") + ";" + rs.getString("Y") + ")@"; emplacement.add(rs.getString("X") + ";" + rs.getString("Y")); } else { SendMsg("ERR#Erreur pas assez de places"); return; } } } catch (SQLException ex) { SendMsg("ERR#Base de donnée inaccessible"); System.err.println("Erreur SQL exception input lorry" + ex.getStackTrace()); return; } // On insert les containers ajoutés dans la BD et on leur met un numéro de réservation + on // réserve leurs places Random rand = new Random(); int resID = rand.nextInt(999999); for (int i = 0; i < idList.length; i++) { String[] coord = emplacement.get(i).toString().split(";"); HashMap<String, String> insertion = new HashMap(); HashMap<String, String> update = new HashMap(); insertion.put("ID_CONTAINER", idList[i]); insertion.put("RESERVATION", Integer.toString(resID)); update.put("ETAT", "1"); try { beanOracle.ecriture("CONTAINERS", insertion); beanOracle.miseAJour("PARC", update, "X=" + coord[0] + " AND Y=" + coord[1]); } catch (requeteException ex) { System.err.println("Erreur d'insertion "); } } SendMsg(reponse); }
// Inclusao de cubos public void incluir( int id, String nome, String tamanho, String tipo, String dificuldade, String imagem, String preco) { String sqlInsert = "INSERT INTO cubo(id, nome, tamanho, tipo, dificuldade, imagem, preco ) VALUES (?, ?, ?, ?, ?, ?, ?)"; try (PreparedStatement st = conn.prepareStatement(sqlInsert)) { // Inclusao dos dados na tabela Cubos st.setInt(1, id); st.setString(2, nome); st.setString(3, tamanho); st.setString(4, tipo); st.setString(5, dificuldade); st.setString(6, imagem); st.setString(7, preco); st.execute(); } catch (Exception e) { e.printStackTrace(); try { conn.rollback(); } catch (SQLException e1) { System.out.print(e1.getStackTrace()); } } }
private void set(SQLException sqle) { if (sqle != null) { sqlstate = sqle.getSQLState(); errorcode = sqle.getErrorCode(); this.setStackTrace(sqle.getStackTrace()); } }
/* (non-Javadoc) * @see com.entrecine4.business.SessionStateService#updateSessionState(models.SessionState) */ @Override public void updateSessionState(SessionState sessionState) { Connection con = Jdbc.getConnection(); try { dao.setConnection(con); dao.update(sessionState); } catch (SQLException e) { Log.log("----TRACE----\n" + e.getStackTrace().toString() + "\n\n\n"); throw new RuntimeException(); } finally { Jdbc.close(con); } }
/* (non-Javadoc) * @see com.entrecine4.business.SessionStateService#findBySession(long) */ @Override public List<SessionState> findBySession(long sessionId) { Connection con = Jdbc.getConnection(); try { dao.setConnection(con); return dao.getBySession(sessionId); } catch (SQLException e) { Log.log("----TRACE----\n" + e.getStackTrace().toString() + "\n\n\n"); throw new RuntimeException(); } finally { Jdbc.close(con); } }
public static SQLException mergeException(List<SQLException> exceptions) { // return new OneToManySQLExceptionsWrapper(exceptions); SQLException first = exceptions.get(0); List<StackTraceElement> stes = new ArrayList<StackTraceElement>(30 * exceptions.size()); // stes.addAll(Arrays.asList(first.getStackTrace())); boolean hasSplit = false; for (StackTraceElement ste : first.getStackTrace()) { stes.add(ste); if (ste == split) { hasSplit = true; } } if (!hasSplit) { stes.add(split); } SQLException current = null; for (int i = 1, n = exceptions.size(); i < n; i++) { // newEx.setNextException(exceptions.get(i)); // current.setNextException(exceptions.get(i)); current = exceptions.get(i); // stes.addAll(Arrays.asList(exceptions.get(i).getStackTrace())); hasSplit = false; for (StackTraceElement ste : current.getStackTrace()) { stes.add(ste); if (ste == split) { hasSplit = true; } } if (!hasSplit) { stes.add(split); } } // newEx.getCause(); first.setStackTrace(stes.toArray(new StackTraceElement[stes.size()])); return first; }
public void excluir(int id) { String sqlDelete = "DELETE FROM cubo WHERE id = ?"; try (PreparedStatement stm = conn.prepareStatement(sqlDelete)) { stm.setInt(1, id); stm.execute(); } catch (Exception e) { e.printStackTrace(); try { conn.rollback(); } catch (SQLException e1) { System.out.print(e1.getStackTrace()); } } }
public Connection getConnection() { Connection c = null; Statement stmt = null; try { Class.forName("org.sqlite.JDBC"); c = DriverManager.getConnection("jdbc:sqlite:resources/data/citystatecountry.db"); System.out.println("Opened database successfully"); } catch (ClassNotFoundException cnf) { System.out.println("could not load driver"); } catch (SQLException sqle) { System.out.println("sql exception:" + sqle.getStackTrace()); } return c; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); dao = new TroubDAO(this.getActivity()); try { dao.open(); } catch (SQLException e) { String error = "Unable to open TroubDAO" + e.getStackTrace(); Log.e(SongListFragment.class.getName(), error); } List<Song> songs = dao.getAllSongs(); // use the SimpleCursorAdapter to show the // elements in a ListView ArrayAdapter<Song> adapter = new ArrayAdapter<Song>(this.getActivity(), android.R.layout.simple_list_item_1, songs); setListAdapter(adapter); setHasOptionsMenu(true); }
/* (non-Javadoc) * @see com.entrecine4.business.SessionStateService#checkFreeSeat(long, long, int, int) */ @Override public boolean checkFreeSeat(long session, long room, int row, int column) { Connection con = Jdbc.getConnection(); Date temp; try { // Get an auxiliar dao to get the date of the session SessionDAO sdao = Factories.persistence.createSessionDAO(); sdao.setConnection(con); dao.setConnection(con); temp = sdao.get(session).getDay(); SessionState st = new SessionState(room, row, column, temp, session); return (dao.get(st) == null) ? true : false; } catch (SQLException e) { Log.log("----TRACE----\n" + e.getStackTrace().toString() + "\n\n\n"); throw new RuntimeException(); } finally { Jdbc.close(con); } }
public static List<Movie> getAllMovies() { String query = "SELECT * FROM movie"; List<Movie> movies = new LinkedList<>(); try (Connection connection = Config.getConnection(); // step 1 Statement statement = connection.createStatement(); // step 2 ResultSet result = statement.executeQuery(query); ) { // step 3 and 4 while (result.next()) { // step 5 Movie movie = new Movie(); // you should be validating the following, // this is just an example to get you started movie.setName(result.getString(1)); movie.setYear(result.getDate(2).getYear()); movie.setUrl(result.getString(3)); movies.add(movie); } } catch (SQLException e) { System.err.println(e.getMessage()); System.err.println(e.getStackTrace()); } return movies; }
public String getHtmlSelectAllgS(String iName, String iSql, String iSelected) { Statement stmt; ResultSet rs; ResultSetMetaData rsmd; String retString = new String(); retString = "\n<SELECT NAME=\"" + iName + "\">"; try { stmt = bdeConnection.createStatement(); stmt.executeQuery(iSql); rs = stmt.getResultSet(); rsmd = rs.getMetaData(); while (rs.next()) { // Der Wert des Auswahlfeldes wird durch das Letzte Feld des Selektierten Datensatzes // bestimmt retString += "\n<OPTION VALUE=\"" + rs.getString(rsmd.getColumnCount()) + "\" "; if (rs.getString(rsmd.getColumnCount()).compareTo(iSelected) == 0) { retString += " SELECTED>"; } else { retString += ">"; } // Alle Felder bis auf das Letzte werden im Auswahlfeld angezeigt... for (int lauf = 1; lauf < rsmd.getColumnCount(); lauf++) { retString += rs.getString(lauf) + " "; } } rs.close(); stmt.close(); } catch (SQLException sqlEx) { sqlEx.printStackTrace(); retString += "<OPTION>" + sqlEx.getStackTrace()[1].toString() + " Methode getHtmlSelectAllg: Fehler beim Datenbankzugriff"; } retString += "</SELECT>\n"; return retString; }
/* 53: */ public void executar() /* 54: */ { /* 55: 61 */ System.out.println("Inicio Coxin"); /* 56: 62 */ Coxins_ERPDAO coxproddao = new Coxins_ERPDAO(); /* 57: 63 */ Coxins_INTERDBDAO coxintdao = new Coxins_INTERDBDAO(); /* 58: */ try /* 59: */ { /* 60: 65 */ for (Coxins_ERP coxin : coxproddao.listarNovos()) { /* 61: 66 */ if ((coxin.getCodCX() != null) && (coxin.getDescrCX() != null)) /* 62: */ { /* 63: 67 */ if (coxintdao.localizarPorId(coxin.getCodCX()).getDescrCX() == null) /* 64: */ { /* 65: 68 */ coxin.setStei(1); /* 66: 69 */ coxintdao.inserir(coxin); /* 67: */ } /* 68: */ else /* 69: */ { /* 70: 71 */ coxin.setStei(1); /* 71: 72 */ coxintdao.atualizar(coxin); /* 72: */ } /* 73: 74 */ coxproddao.atualizar(coxin); /* 74: 75 */ System.out.println("Coxin: " + coxin.getCodCX()); /* 75: */ } /* 76: */ } /* 77: */ } /* 78: */ catch (SQLException ex) /* 79: */ { /* 80: 79 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 81: */ } /* 82: */ catch (ClassNotFoundException ex) /* 83: */ { /* 84: 81 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 85: */ } /* 86: */ catch (Exception ex) /* 87: */ { /* 88: 83 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 89: */ } /* 90: 85 */ System.out.println("Fim Coxin"); /* 91: 86 */ System.out.println("Inicio Desenho"); /* 92: 87 */ Desreforma_ERPDAO desproddao = new Desreforma_ERPDAO(); /* 93: 88 */ Desreforma_INTERDBDAO desintdao = new Desreforma_INTERDBDAO(); /* 94: */ try /* 95: */ { /* 96: 90 */ for (Desreforma_ERP desenho : desproddao.listarNovos()) { /* 97: 91 */ if ((desenho.getCodDE() != null) && (desenho.getDescrDE() != null)) /* 98: */ { /* 99: 92 */ if (desintdao.localizarPorID(desenho.getCodDE()).getCodDE() == null) /* 100: */ { /* 101: 93 */ desenho.setStEI(1); /* 102: 94 */ desintdao.inserir(desenho); /* 103: */ } /* 104: */ else /* 105: */ { /* 106: 96 */ desenho.setStEI(1); /* 107: 97 */ desintdao.atualizar(desenho); /* 108: */ } /* 109: 99 */ desproddao.atualizar(desenho); /* 110:100 */ System.out.println("Desenho: " + desenho.getCodDE()); /* 111: */ } /* 112: */ } /* 113: */ } /* 114: */ catch (SQLException ex) /* 115: */ { /* 116:104 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 117: */ } /* 118: */ catch (ClassNotFoundException ex) /* 119: */ { /* 120:106 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 121: */ } /* 122: */ catch (Exception ex) /* 123: */ { /* 124:108 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 125: */ } /* 126:110 */ System.out.println("Fim Desenho"); /* 127:111 */ System.out.println("Inicio Laudo"); /* 128:112 */ Laudosrec_ERPDAO lauproddao = new Laudosrec_ERPDAO(); /* 129:113 */ Laudosrec_INTERDBDAO lauintdao = new Laudosrec_INTERDBDAO(); /* 130: */ try /* 131: */ { /* 132:115 */ for (Laudosrec_ERP laudo : lauproddao.listarNovos()) { /* 133:116 */ if ((laudo.getCodLA() != null) && (laudo.getDescrLA() != null)) /* 134: */ { /* 135:117 */ if (lauintdao.localizarPorID(laudo.getCodLA()).getCodLA() == null) /* 136: */ { /* 137:118 */ laudo.setStEI(1); /* 138:119 */ lauintdao.inserir(laudo); /* 139: */ } /* 140: */ else /* 141: */ { /* 142:121 */ laudo.setStEI(1); /* 143:122 */ lauintdao.atualizar(laudo); /* 144: */ } /* 145:124 */ lauproddao.atualizar(laudo); /* 146:125 */ System.out.println("Laudo: " + laudo.getCodLA()); /* 147: */ } /* 148: */ } /* 149: */ } /* 150: */ catch (SQLException ex) /* 151: */ { /* 152:130 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 153: */ } /* 154: */ catch (ClassNotFoundException ex) /* 155: */ { /* 156:132 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 157: */ } /* 158: */ catch (Exception ex) /* 159: */ { /* 160:134 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 161: */ } /* 162:136 */ System.out.println("Fim Laudo"); /* 163:137 */ System.out.println("Inicio Marca"); /* 164:138 */ Marcas_ERPDAO marproddao = new Marcas_ERPDAO(); /* 165:139 */ Marcas_INTERDBDAO marintdao = new Marcas_INTERDBDAO(); /* 166: */ try /* 167: */ { /* 168:141 */ for (Marcas_ERP marca : marproddao.listarNovos()) { /* 169:142 */ if ((marca.getCodMA() != null) && (marca.getDescrMA() != null)) /* 170: */ { /* 171:143 */ if (marintdao.localizarPorID(marca.getCodMA()).getDescrMA() == null) /* 172: */ { /* 173:144 */ marca.setStEI(1); /* 174:145 */ marintdao.inserir(marca); /* 175: */ } /* 176: */ else /* 177: */ { /* 178:147 */ marca.setStEI(1); /* 179:148 */ marintdao.atualizar(marca); /* 180: */ } /* 181:150 */ marproddao.atualizar(marca); /* 182:151 */ System.out.println("Marca " + marca.getCodMA()); /* 183: */ } /* 184: */ } /* 185: */ } /* 186: */ catch (SQLException ex) /* 187: */ { /* 188:155 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 189: */ } /* 190: */ catch (ClassNotFoundException ex) /* 191: */ { /* 192:157 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 193: */ } /* 194: */ catch (Exception ex) /* 195: */ { /* 196:159 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 197: */ } /* 198:161 */ System.out.println("Fim Marca"); /* 199:162 */ System.out.println("Inicio Medida"); /* 200:163 */ Medidas_ERPDAO medproddao = new Medidas_ERPDAO(); /* 201:164 */ Medidas_INTERDBDAO medintdao = new Medidas_INTERDBDAO(); /* 202: */ try /* 203: */ { /* 204:166 */ for (Medidas_ERP medida : medproddao.listarNovos()) { /* 205:167 */ if ((medida.getCodME() != null) && (medida.getDescrME() != null)) /* 206: */ { /* 207:168 */ if (medintdao.localizarPorID(medida.getCodME()).getCodME() == null) /* 208: */ { /* 209:169 */ medida.setStEI(1); /* 210:170 */ medintdao.inserir(medida); /* 211: */ } /* 212: */ else /* 213: */ { /* 214:172 */ medida.setStEI(1); /* 215:173 */ medintdao.atualizar(medida); /* 216: */ } /* 217:175 */ medproddao.atualizar(medida); /* 218:176 */ System.out.println("Medida: " + medida.getCodME()); /* 219: */ } /* 220: */ } /* 221: */ } /* 222: */ catch (SQLException ex) /* 223: */ { /* 224:181 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 225: */ } /* 226: */ catch (ClassNotFoundException ex) /* 227: */ { /* 228:183 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 229: */ } /* 230: */ catch (Exception ex) /* 231: */ { /* 232:185 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 233: */ } /* 234:187 */ System.out.println("Fim Medidas"); /* 235:188 */ System.out.println("Inicio Modelo"); /* 236:189 */ Modelos_ERPDAO modproddao = new Modelos_ERPDAO(); /* 237:190 */ Modelos_INTERDBDAO modintdao = new Modelos_INTERDBDAO(); /* 238: */ try /* 239: */ { /* 240:192 */ for (Modelos_ERP modelo : modproddao.listarNovos()) { /* 241:193 */ if ((modelo.getCodMO() != null) && (modelo.getDescrMO() != null)) /* 242: */ { /* 243:194 */ if (modintdao.localizarPorID(modelo.getCodMO()).getCodMO() == null) /* 244: */ { /* 245:195 */ modelo.setStEI(1); /* 246:196 */ modintdao.inserir(modelo); /* 247: */ } /* 248: */ else /* 249: */ { /* 250:198 */ modelo.setStEI(1); /* 251:199 */ modintdao.atualizar(modelo); /* 252: */ } /* 253:201 */ modproddao.atualizar(modelo); /* 254:202 */ System.out.println("Modelos: " + modelo.getCodMO()); /* 255: */ } /* 256: */ } /* 257: */ } /* 258: */ catch (SQLException ex) /* 259: */ { /* 260:206 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 261: */ } /* 262: */ catch (ClassNotFoundException ex) /* 263: */ { /* 264:208 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 265: */ } /* 266: */ catch (Exception ex) /* 267: */ { /* 268:210 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 269: */ } /* 270:212 */ System.out.println("Fim Modelo"); /* 271:213 */ System.out.println("Inicio OS"); /* 272:214 */ OS_ERPDAO osproddao = new OS_ERPDAO(); /* 273:215 */ OS_INTERDBDAO osintdao = new OS_INTERDBDAO(); /* 274: */ try /* 275: */ { /* 276:217 */ for (OS_ERP os : osproddao.listarNovos()) { /* 277:218 */ if ((os.getNrOS() != null) || (os.getNrMatricula() != null)) /* 278: */ { /* 279:219 */ if (osintdao.localizarPorID(os.getNrOS().intValue()).getNrOS() == null) /* 280: */ { /* 281:220 */ if (os.getStEI() == 1) { /* 282:221 */ os.setStEI(2); /* 283: */ } else { /* 284:223 */ os.setStEI(5); /* 285: */ } /* 286:225 */ os.setERPID("1"); /* 287:226 */ osintdao.inserir(os); /* 288: */ } /* 289:236 */ osproddao.atualizar(os); /* 290:237 */ System.out.println("Os: " + os.getNrOS() + " Status" + os.getStEI()); /* 291: */ } /* 292: */ } /* 293: */ } /* 294: */ catch (SQLException ex) /* 295: */ { /* 296:241 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 297: */ } /* 298: */ catch (ClassNotFoundException ex) /* 299: */ { /* 300:243 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 301: */ } /* 302: */ catch (Exception ex) /* 303: */ { /* 304:245 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 305: */ } /* 306:247 */ System.out.println("Fim Os"); /* 307:248 */ System.out.println("Inicio Detalhameto OS"); /* 308:249 */ Osvr_ERPDAO osvrERPDAO = new Osvr_ERPDAO(); /* 309:250 */ Osvr_INTERDBDAO osvrINTERDBDAO = new Osvr_INTERDBDAO(); /* 310: */ try /* 311: */ { /* 312:253 */ for (Osvr_ERP osvr : osvrERPDAO.listarNovos()) { /* 313:254 */ if ((osvr.getNrOS() != null) && (osvr.getCodigoReg() != null)) /* 314: */ { /* 315:255 */ if (osvrINTERDBDAO .localizarPorID( osvr.getNrOS(), osvr.getTipoReg(), osvr.getCodigoReg(), osvr.getOSVRID()) .getNrOS() == null) /* 316: */ { /* 317:258 */ osvr.setFilialTit("002"); /* 318:259 */ osvrINTERDBDAO.inserir(osvr); /* 319: */ } /* 320: */ else /* 321: */ { /* 322:261 */ osvr.setFilialTit("002"); /* 323:262 */ osvrINTERDBDAO.atualizar(osvr); /* 324: */ } /* 325:264 */ osvrERPDAO.atualizar(osvr); /* 326:265 */ System.out.println( "Detalhamenento OS: " + osvr.getNrOS() + " Tipo: " + osvr.getTipoReg() + " Codigo Reg: " + osvr.getCodigoReg()); /* 327: */ } /* 328: */ } /* 329: */ } /* 330: */ catch (SQLException ex) /* 331: */ { /* 332:271 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 333: */ } /* 334: */ catch (ClassNotFoundException ex) /* 335: */ { /* 336:273 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 337: */ } /* 338: */ catch (Exception ex) /* 339: */ { /* 340:275 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 341: */ } /* 342:278 */ System.out.println("Inicio Parcelas"); /* 343:279 */ Parcprazos_ERPDAO parpdao = new Parcprazos_ERPDAO(); /* 344:280 */ Parcprazos_INTERDBDAO paridao = new Parcprazos_INTERDBDAO(); /* 345: */ try /* 346: */ { /* 347:282 */ for (Parcprazos_ERP parc : parpdao.listarNovos()) { /* 348:283 */ if ((parc.getCodPR() != null) && (parc.getParcPR() != null)) /* 349: */ { /* 350:284 */ if (paridao.localizarPorID(parc.getCodPR()).getCodPR() == null) /* 351: */ { /* 352:285 */ parc.setStEI(1); /* 353:286 */ paridao.inserir(parc); /* 354: */ } /* 355: */ else /* 356: */ { /* 357:288 */ parc.setStEI(1); /* 358:289 */ paridao.atualizar(parc); /* 359: */ } /* 360:291 */ parpdao.atualizar(parc); /* 361:292 */ System.out.println("Parcelas: " + parc.getCodPR()); /* 362: */ } /* 363: */ } /* 364: */ } /* 365: */ catch (SQLException ex) /* 366: */ { Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 368: */ } /* 369: */ catch (ClassNotFoundException ex) /* 370: */ { Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 372: */ } /* 373: */ catch (Exception ex) /* 374: */ { Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 376: */ } /* 377:302 */ System.out.println("Fim parcelas"); /* 378:303 */ System.out.println("Inicio Prazo"); /* 379:304 */ Prazos_ERPDAO prapdao = new Prazos_ERPDAO(); /* 380:305 */ Prazos_INTERDBDAO praidao = new Prazos_INTERDBDAO(); /* 381: */ try /* 382: */ { /* 383:307 */ for (Prazos_ERP prazo : prapdao.listarNovos()) { /* 384:308 */ if ((prazo.getCodPR() != null) && (prazo.getDescrPR() != null)) /* 385: */ { /* 386:309 */ if (praidao.localizarPorID(prazo.getCodPR()).getDescrPR() == null) /* 387: */ { /* 388:310 */ prazo.setStEI(1); /* 389:311 */ praidao.inserir(prazo); /* 390: */ } /* 391: */ else /* 392: */ { /* 393:313 */ prazo.setStEI(1); /* 394:314 */ praidao.atualizar(prazo); /* 395: */ } /* 396:316 */ prapdao.atualizar(prazo); /* 397:317 */ System.out.println("Prazo: " + prazo.getCodPR()); /* 398: */ } /* 399: */ } /* 400: */ } /* 401: */ catch (SQLException ex) /* 402: */ { /* 403:321 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 404: */ } /* 405: */ catch (ClassNotFoundException ex) /* 406: */ { /* 407:323 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 408: */ } /* 409: */ catch (Exception ex) /* 410: */ { /* 411:325 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 412: */ } /* 413:327 */ System.out.println("Fim Prazos"); /* 414:328 */ System.out.println("Inicio Regioes"); /* 415:329 */ Regioes_ERPDAO regpdao = new Regioes_ERPDAO(); /* 416:330 */ Regioes_INTERDBDAO regidao = new Regioes_INTERDBDAO(); /* 417: */ try /* 418: */ { /* 419:333 */ for (Regioes_ERP regiao : regpdao.listarNovos()) { /* 420:334 */ if ((regiao.getCodRE() != null) && (regiao.getDescrRE() != null)) /* 421: */ { /* 422:335 */ if (regidao.localizarPorID(regiao.getCodRE()).getDescrRE() == null) /* 423: */ { /* 424:336 */ regiao.setStEI(1); /* 425:337 */ regidao.inserir(regiao); /* 426: */ } /* 427: */ else /* 428: */ { /* 429:339 */ regiao.setStEI(1); /* 430:340 */ regidao.atualizar(regiao); /* 431: */ } /* 432:342 */ regpdao.atualizar(regiao); /* 433:343 */ System.out.println("Regiao" + regiao.getCodRE()); /* 434: */ } /* 435: */ } /* 436: */ } /* 437: */ catch (SQLException ex) /* 438: */ { /* 439:348 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 440: */ } /* 441: */ catch (ClassNotFoundException ex) /* 442: */ { /* 443:350 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 444: */ } /* 445: */ catch (Exception ex) /* 446: */ { /* 447:352 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 448: */ } /* 449:354 */ System.out.println("Fim Regioes"); /* 450:355 */ System.out.println("Inicio Reparos"); /* 451:356 */ Reparos_ERPDAO reppdao = new Reparos_ERPDAO(); /* 452:357 */ Reparos_INTERDBDAO repidao = new Reparos_INTERDBDAO(); /* 453: */ try /* 454: */ { /* 455:359 */ for (Reparos_ERP reparo : reppdao.listarNovos()) { /* 456:360 */ if ((reparo.getCodRP() != null) && (reparo.getDescrRP() != null)) /* 457: */ { /* 458:361 */ if (repidao.localizarPorID(reparo.getCodRP()).getDescrRP() == null) /* 459: */ { /* 460:362 */ reparo.setStei(1); /* 461:363 */ repidao.inserir(reparo); /* 462: */ } /* 463: */ else /* 464: */ { /* 465:365 */ reparo.setStei(1); /* 466:366 */ repidao.atualizar(reparo); /* 467: */ } /* 468:368 */ reppdao.atualizar(reparo); /* 469:369 */ System.out.println("Reparo: " + reparo.getCodRP()); /* 470: */ } /* 471: */ } /* 472: */ } /* 473: */ catch (SQLException ex) /* 474: */ { /* 475:374 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 476: */ } /* 477: */ catch (ClassNotFoundException ex) /* 478: */ { /* 479:376 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 480: */ } /* 481: */ catch (Exception ex) /* 482: */ { /* 483:378 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 484: */ } /* 485:380 */ System.out.println("Fim reparos"); /* 486:381 */ System.out.println("Inicio Resp"); /* 487:382 */ Resp_CliDAO resppdao = new Resp_CliDAO(); /* 488:383 */ Resp_CliINTERDBDAO respidao = new Resp_CliINTERDBDAO(); /* 489: */ try /* 490: */ { /* 491:385 */ for (Resp_Cli resp : resppdao.listarNovos()) { /* 492:386 */ if ((resp.getCNPJCPF() != null) && (resp.getRespAVencer() != null)) /* 493: */ { /* 494:387 */ if (respidao.localizarPorID(resp.getCNPJCPF()).getCNPJCPF() == null) /* 495: */ { /* 496:388 */ resp.setStEI(1); /* 497:389 */ respidao.inserir(resp); /* 498: */ } /* 499: */ else /* 500: */ { /* 501:391 */ resp.setStEI(1); /* 502:392 */ respidao.atualizar(resp); /* 503: */ } /* 504:394 */ resppdao.atualizar(resp); /* 505:395 */ System.out.println("Responsabilidade: " + resp.getCNPJCPF()); /* 506: */ } /* 507: */ } /* 508: */ } /* 509: */ catch (SQLException ex) /* 510: */ { /* 511:400 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 512: */ } /* 513: */ catch (ClassNotFoundException ex) /* 514: */ { /* 515:402 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 516: */ } /* 517: */ catch (Exception ex) /* 518: */ { /* 519:404 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 520: */ } /* 521:406 */ System.out.println("Fim Resp"); /* 522:407 */ System.out.println("Inicio serv"); /* 523:408 */ Servicos_ERPDAO servpdao = new Servicos_ERPDAO(); /* 524:409 */ Servicos_INTERDBDAO servidao = new Servicos_INTERDBDAO(); /* 525: */ try /* 526: */ { /* 527:411 */ for (Servicos_ERP serv : servpdao.listarNovos()) { /* 528:412 */ if ((serv.getCodSE() != null) && (serv.getDescrSE() != null)) /* 529: */ { /* 530:413 */ if (servidao.localizarPorID(serv.getCodSE()).getDescrSE() == null) /* 531: */ { /* 532:414 */ serv.setStei(1); /* 533:415 */ servidao.inserir(serv); /* 534: */ } /* 535: */ else /* 536: */ { /* 537:417 */ serv.setStei(1); /* 538:418 */ servidao.atualizar(serv); /* 539: */ } /* 540:420 */ servpdao.atualizar(serv); /* 541:421 */ System.out.println("Servicos: " + serv.getCodSE()); /* 542: */ } /* 543: */ } /* 544: */ } /* 545: */ catch (SQLException ex) /* 546: */ { /* 547:426 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro); /* 548: */ } /* 549: */ catch (ClassNotFoundException ex) /* 550: */ { /* 551:428 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro2); /* 552: */ } /* 553: */ catch (Exception ex) /* 554: */ { /* 555:430 */ Logger.getLogger(Integracao.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro3 = ""; for (int i = 0; i < st.length; i++) { erro3 += st[i].toString() + "\n"; } new Geralog().enviar("Integrador", erro3); /* 556: */ } /* 557:432 */ System.out.println("Fim serv"); /* 558: */ }
private void listOperation(String[] request) { String Select = "ID_MOUVEMENT, MOUVEMENTS.ID_CONTAINER, ID_TRANSPORTEUR_ENTRANT, DATE_ARRIVEE, ID_TRANSPORTEUR_SORTANT, POIDS, DATE_DEPART, DESTINATION, ID_SOCIETE"; String From = "MOUVEMENTS INNER JOIN CONTAINERS ON MOUVEMENTS.ID_CONTAINER = CONTAINERS.ID_CONTAINER"; String Where = null; if (request[1].equals("societe")) Where = "CONTAINERS.ID_SOCIETE = '" + request[2] + "'"; if (request[1].equals("destination")) Where = "DESTINATION = '" + request[2] + "'"; if (request[1].equals("date")) Where = "To_date(DATE_ARRIVEE, 'DD/MM/YYYY') BETWEEN To_date('" + request[2] + "', 'DD/MM/YYYY') AND To_date('" + request[3] + "', 'DD/MM/YYYY')"; if (Where == null) { SendMsg("ERR#Recherche impossible sur ce critere"); return; } ResultSet rs = null; try { rs = beanOracle.selection(Select, From, Where); } catch (SQLException ex) { SendMsg("ERR#Base de donnee inaccessible"); System.err.println("Erreur SQL exception input lorry" + ex.getStackTrace()); return; } boolean empty = true; String message = ""; try { while (rs.next()) { empty = false; message = message + rs.getString("ID_MOUVEMENT") + " --- " + rs.getString("ID_CONTAINER") + " --- " + rs.getString("ID_TRANSPORTEUR_ENTRANT") + " --- "; message = message + rs.getString("DATE_ARRIVEE") + " --- " + rs.getString("ID_TRANSPORTEUR_SORTANT") + " --- " + rs.getString("POIDS") + " --- "; message = message + rs.getString("DATE_DEPART") + " --- " + rs.getString("DESTINATION") + " --- " + rs.getString("ID_SOCIETE") + "#"; } } catch (SQLException ex) { SendMsg("ERR#Base de donnee inaccessible"); System.err.println("Erreur SQL exception input lorry" + ex.getStackTrace()); return; } if (empty) { SendMsg("ERR#Aucun resultats pour la societe " + request[2]); return; } SendMsg("ACK#" + message); }
private void inputLorry(String[] request) { ResultSet rs = null; try { rs = beanOracle.selection("ID_CONTAINER", "CONTAINERS", "RESERVATION = '" + request[1] + "'"); } catch (SQLException ex) { SendMsg("ERR#Base de donnée inaccessible"); System.err.println("Erreur SQL exception input lorry"); return; } boolean isResultEmpty = true; int nbrElemParc = 0; String[] idList = request[2].split("@"); System.out.println(request[2]); try { while (rs.next()) { nbrElemParc++; isResultEmpty = false; String curId = null; String id = rs.getString("ID_CONTAINER"); boolean invalidContainerID = true; for (String s : idList) { System.out.println(s + "---" + id); curId = s; if (s.equals(id)) { invalidContainerID = false; break; } } if (invalidContainerID) { SendMsg("ERR#Le container " + curId + " ne fait pas partie de la reservation"); return; } if (nbrElemParc >= idList.length) break; } } catch (SQLException ex) { SendMsg("ERR#Base de donnée inaccessible"); System.err.println("Erreur SQL exception input lorry resultat"); return; } if (isResultEmpty) { SendMsg("ERR#Le numero de reservation demande n'existe pas"); return; } try { rs = beanOracle.selection("X, Y", "PARC", "ETAT=1"); } catch (SQLException ex) { SendMsg("ERR#Base de donnée inaccessible"); System.err.println("Erreur SQL exception input lorry" + ex.getStackTrace()); return; } String reponse = "ACK#"; try { for (int i = 0; i < idList.length; i++) { if (rs.next()) { reponse = reponse + idList[i] + "==>(" + rs.getString("X") + ";" + rs.getString("Y") + ")@"; } else { SendMsg("ERR#Erreur pas assez de places reservees"); return; } } } catch (SQLException ex) { SendMsg("ERR#Base de donnee inaccessible"); System.err.println("Erreur SQL exception input lorry" + ex.getStackTrace()); return; } SendMsg(reponse); }
private void addCustomer() { if (checkInput()) { String salt = ""; String password = ""; try { salt = secman.createSalt(); password = secman.encodePassword(textFieldPassword.getText(), salt); } catch (Exception e) { new ErrorJDialog( this.luggageControl, true, "Required algorithm does not exists", e.getStackTrace()); return; } String queryInsertUser = "******" + "(`username`,`password`,`salt`,`email`,`firstname`,`surname`,`cellphone`,`birthday`,`gender`,`nationality`,`adress`,`city`,`postcode`,`image`,`permission`)" + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; String[] values = new String[15]; String[] types = new String[15]; values[0] = textFieldUsername.getText(); values[1] = password; values[2] = salt; values[3] = textFieldEmail.getText(); values[4] = textFieldFirstname.getText(); values[5] = textFieldSurname.getText(); values[6] = textFieldCellphone.getText(); values[7] = textFieldBirthday.getText(); values[8] = comboBoxGender.getSelectedItem().toString(); values[9] = textFieldNationality.getText(); values[10] = textFieldAdress.getText(); values[11] = textFieldCity.getText(); values[12] = textFieldPostalcode.getText(); values[13] = imageBase64; values[14] = comboBoxProfession.getSelectedIndex() + ""; types[0] = "String"; types[1] = "String"; types[2] = "String"; types[3] = "String"; types[4] = "String"; types[5] = "String"; types[6] = "String"; types[7] = "String"; types[8] = "String"; types[9] = "String"; types[10] = "String"; types[11] = "String"; types[12] = "String"; types[13] = "String"; types[14] = "Int"; try { db.queryManipulation(queryInsertUser, values, types); } catch (SQLException e) { new ErrorJDialog(this.luggageControl, true, e.getMessage(), e.getStackTrace()); } this.clearFields(); this.luggageControl.switchJPanel(this.luggageControl.HOME_SCREEN_ADMINISTRATOR); } }
public void getBlockInteractions(Player player, Block block, Interaction interaction) { try { player.sendMessage( ChatColor.DARK_RED + "BlockLog History (" + getConfig().getString("blocklog.results") + " Last Edits)"); ArrayList<LoggedInteraction> Interactions = plugin.getInteractions(); int BlockNumber = 0; int BlockCount = 0; int BlockSize = Interactions.size(); Location BlockLocation = block.getLocation(); while (BlockSize > BlockNumber) { LoggedInteraction LInteraction = Interactions.get(BlockNumber); if (LInteraction.getX() == BlockLocation.getX() && LInteraction.getY() == BlockLocation.getY() && LInteraction.getZ() == BlockLocation.getZ() && LInteraction.getWorld() == BlockLocation.getWorld()) { if (BlockCount == getConfig().getInt("blocklog.results")) break; String str = ""; if (interaction == Interaction.CHEST || interaction == Interaction.DISPENSER) str = "opened this"; else str = "used this"; String name = interaction.getMaterial().name(); Calendar calendar = GregorianCalendar.getInstance(); calendar.setTimeInMillis(LInteraction.getDate() * 1000); String date = calendar.get(Calendar.DAY_OF_MONTH) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-" + calendar.get(Calendar.YEAR) + " " + calendar.get(Calendar.HOUR_OF_DAY) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND); player.sendMessage( ChatColor.BLUE + "[" + date + "] " + ChatColor.GOLD + LInteraction.getPlayerName() + " " + ChatColor.DARK_GREEN + str + " " + ChatColor.GOLD + name); BlockCount++; } BlockNumber++; } if (BlockCount < getConfig().getInt("blocklog.results")) { Connection conn = plugin.conn; Statement stmt = conn.createStatement(); double x = BlockLocation.getX(); double y = BlockLocation.getY(); double z = BlockLocation.getZ(); ResultSet rs = stmt.executeQuery( "SELECT player, FROM_UNIXTIME(date, '%d-%m-%Y %H:%i:%s') AS date FROM blocklog_interactions WHERE x = '" + x + "' AND y = '" + y + "' AND z = '" + z + "' AND world = '" + BlockLocation.getWorld().getName() + "' ORDER BY date DESC LIMIT " + (getConfig().getInt("blocklog.results") - BlockCount)); while (rs.next()) { String str = ""; if (interaction == Interaction.CHEST || interaction == Interaction.DISPENSER || interaction == Interaction.DOOR || interaction == Interaction.TRAP_DOOR) str = "opened a"; else str = "used a"; String name = interaction.getMaterial().name(); player.sendMessage( ChatColor.BLUE + "[" + rs.getString("date") + "] " + ChatColor.GOLD + rs.getString("player") + " " + ChatColor.DARK_GREEN + str + " " + ChatColor.GOLD + name); } } } catch (SQLException e) { e.getStackTrace(); } }
public void getBlockEdits(Player player, Block block) { try { player.sendMessage( ChatColor.DARK_RED + "BlockLog History (" + getConfig().getString("blocklog.results") + " Last Edits)"); Integer BlockNumber = 0; Integer BlockCount = 0; Integer BlockSize = plugin.getBlocks().size(); Location BlockLocation = block.getLocation(); while (BlockSize > BlockNumber) { LoggedBlock LBlock = plugin.getBlocks().get(BlockNumber); if (LBlock.getX() == BlockLocation.getX() && LBlock.getY() == BlockLocation.getY() && LBlock.getZ() == BlockLocation.getZ() && LBlock.getWorld() == BlockLocation.getWorld()) { if (BlockCount == getConfig().getInt("blocklog.results")) break; Calendar calendar = GregorianCalendar.getInstance(); calendar.setTimeInMillis(LBlock.getDate() * 1000); String date = calendar.get(Calendar.DAY_OF_MONTH) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-" + calendar.get(Calendar.YEAR) + " " + calendar.get(Calendar.HOUR_OF_DAY) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND); String name = Material.getMaterial(LBlock.getBlockId()).toString(); int type = LBlock.getTypeId(); if (type == 0) player.sendMessage( ChatColor.BLUE + "[" + date + "] " + ChatColor.GOLD + LBlock.getPlayerName() + " (" + LBlock.getEntityName() + ")" + ChatColor.DARK_GREEN + " broke a " + ChatColor.GOLD + name); else if (type == 1) player.sendMessage( ChatColor.BLUE + "[" + date + "] " + ChatColor.GOLD + LBlock.getPlayerName() + " (" + LBlock.getEntityName() + ")" + ChatColor.DARK_GREEN + " placed a " + ChatColor.GOLD + name); else if (type == 2) player.sendMessage( ChatColor.BLUE + "[" + date + "] " + ChatColor.GOLD + LBlock.getPlayerName() + " (" + LBlock.getEntityName() + ")" + ChatColor.DARK_GREEN + " burned a " + ChatColor.GOLD + name); else if (type == 3 || type == 10 || type == 11 || type == 12) player.sendMessage( ChatColor.BLUE + "[" + date + "] " + ChatColor.GOLD + LBlock.getPlayerName() + " (" + LBlock.getEntityName() + ")" + ChatColor.DARK_GREEN + " blew a " + ChatColor.GOLD + name + ChatColor.DARK_GREEN + " up"); else if (type == 4) player.sendMessage( ChatColor.BLUE + "[" + date + "] " + ChatColor.DARK_GREEN + "A " + ChatColor.GOLD + name + ChatColor.DARK_GREEN + " decayed"); else if (type == 5) player.sendMessage( ChatColor.BLUE + "[" + date + "] " + ChatColor.GOLD + LBlock.getPlayerName() + " (" + LBlock.getEntityName() + ")" + ChatColor.DARK_GREEN + " grew a " + ChatColor.GOLD + name); else if (type == 6 || type == 7 || type == 8) player.sendMessage( ChatColor.BLUE + "[" + date + "] " + ChatColor.GOLD + LBlock.getPlayerName() + " (" + LBlock.getEntityName() + ")" + ChatColor.DARK_GREEN + " created a " + ChatColor.GOLD + name); else if (type == 9) player.sendMessage( ChatColor.BLUE + "[" + date + "] " + ChatColor.DARK_GREEN + "A " + ChatColor.GOLD + name + ChatColor.DARK_GREEN + " faded"); BlockCount++; } BlockNumber++; } if (BlockCount < getConfig().getInt("blocklog.results")) { Connection conn = plugin.conn; Statement stmt = conn.createStatement(); Integer x = block.getX(); Integer y = block.getY(); Integer z = block.getZ(); ResultSet rs = stmt.executeQuery( "SELECT entity, trigered, block_id, type, FROM_UNIXTIME(date, '%d-%m-%Y %H:%i:%s') AS date FROM blocklog_blocks WHERE x = '" + x + "' AND y = '" + y + "' AND z = '" + z + "' AND world = '" + block.getWorld().getName() + "' ORDER BY date DESC LIMIT " + (getConfig().getInt("blocklog.results") - BlockCount)); while (rs.next()) { String name = Material.getMaterial(rs.getInt("block_id")).toString(); int type = rs.getInt("type"); if (type == 0) player.sendMessage( ChatColor.BLUE + "[" + rs.getString("date") + "] " + ChatColor.GOLD + rs.getString("trigered") + " (" + rs.getString("entity") + ")" + ChatColor.DARK_GREEN + " broke a " + ChatColor.GOLD + name); else if (type == 1) player.sendMessage( ChatColor.BLUE + "[" + rs.getString("date") + "] " + ChatColor.GOLD + rs.getString("trigered") + " (" + rs.getString("entity") + ")" + ChatColor.DARK_GREEN + " placed a " + ChatColor.GOLD + name); else if (type == 2) player.sendMessage( ChatColor.BLUE + "[" + rs.getString("date") + "] " + ChatColor.GOLD + rs.getString("trigered") + " (" + rs.getString("entity") + ")" + ChatColor.DARK_GREEN + " burned a " + ChatColor.GOLD + name); else if (type == 3 || type == 10 || type == 11 || type == 12) player.sendMessage( ChatColor.BLUE + "[" + rs.getString("date") + "] " + ChatColor.GOLD + rs.getString("trigered") + " (" + rs.getString("entity") + ")" + ChatColor.DARK_GREEN + " blew a " + ChatColor.GOLD + name + ChatColor.DARK_GREEN + " up"); else if (type == 4) player.sendMessage( ChatColor.BLUE + "[" + rs.getString("date") + "] " + ChatColor.DARK_GREEN + "A " + ChatColor.GOLD + name + ChatColor.DARK_GREEN + " decayed"); else if (type == 5) player.sendMessage( ChatColor.BLUE + "[" + rs.getString("date") + "] " + ChatColor.GOLD + rs.getString("trigered") + " (" + rs.getString("entity") + ")" + ChatColor.DARK_GREEN + " grew a " + ChatColor.GOLD + name); else if (type == 6 || type == 7 || type == 8) player.sendMessage( ChatColor.BLUE + "[" + rs.getString("date") + "] " + ChatColor.GOLD + rs.getString("trigered") + " (" + rs.getString("entity") + ")" + ChatColor.DARK_GREEN + " created a " + ChatColor.GOLD + name); else if (type == 9) player.sendMessage( ChatColor.BLUE + "[" + rs.getString("date") + "] " + ChatColor.DARK_GREEN + "A " + ChatColor.GOLD + name + ChatColor.DARK_GREEN + " faded"); } } } catch (SQLException e) { e.getStackTrace(); } }