public void executeSingleUpdate(String currentInstruction) throws Exception { if (traceMode) { String printableInstruction = StringUtil.sReplace("\r\n", " ", currentInstruction); printableInstruction = StringUtil.sReplace("\t", " ", printableInstruction); if (printableInstruction.length() > 147) { printableInstruction = printableInstruction.substring(0, 146) + "..."; } console.printMessage("\t\t>" + printableInstruction); } Statement stmt = connection.createStatement(); try { stmt.executeUpdate(currentInstruction); } catch (Exception e) { throw new Exception( "\r\n***ERROR RETURNED BY THE RDBMS : " + e.getMessage() + "\r\n***STATEMENT ON ERROR IS : " + currentInstruction + " " + pieceName, e); } finally { DbUtils.closeQuietly(stmt); } }
// Contructeur utilisé pour une pièce de type fichier public DBBuilderPiece(Console console, String pieceName, String actionName, boolean traceMode) throws Exception { this.console = console; this.traceMode = traceMode; this.actionName = actionName; this.pieceName = pieceName; if (pieceName.endsWith(".jar")) { content = ""; } else { // charge son contenu sauf pour un jar qui doit être dans le classpath File myFile = new File(pieceName); if (!myFile.exists() || !myFile.isFile() || !myFile.canRead()) { console.printMessage("\t\t***Unable to load : " + pieceName); throw new Exception("Unable to find or load : " + pieceName); } int fileSize = (int) myFile.length(); byte[] data = new byte[fileSize]; DataInputStream in = new DataInputStream(new FileInputStream(pieceName)); try { in.readFully(data); } finally { IOUtils.closeQuietly(in); } content = new String(data, Charsets.UTF_8); } Properties res = DBBuilder.getdbBuilderResources(); if (res != null) { for (Enumeration e = res.keys(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); String value = res.getProperty(key); content = StringUtil.sReplace("${" + key + '}', value, content); } } }
public void executeSingleProcedure(String currentInstruction, DbProcParameter[] params) throws Exception { if (traceMode) { String printableInstruction = StringUtil.sReplace("\n", " ", currentInstruction); printableInstruction = StringUtil.sReplace("\t", " ", printableInstruction); if (printableInstruction.length() > 147) { printableInstruction = printableInstruction.substring(0, 146) + "..."; } console.printMessage("\t\t>" + printableInstruction); } try { QueryExecutor.executeProcedure(connection, currentInstruction, params); } catch (Exception e) { throw new Exception( "\r\n***ERROR RETURNED BY THE RDBMS : " + e.getMessage() + "\r\n***STATEMENT ON ERROR IS : " + currentInstruction, e); } }