public void destroy() { SQLProcessor processor = getProcessor(null); if (processor == null) { System.err.println("Could not obtain SQLProcessor"); } for (int i = 0; i < destroySQL.length; i++) { try { processor.processUpdate(initSQL[i], null); } catch (SQLException e) { System.err.println("Could not delete tables"); e.printStackTrace(); } } }
public void init() throws HammurapiException { // super.init(); SQLProcessor processor = getProcessor(null); if (processor == null) { throw new HammurapiException("Could not obtain SQLProcessor"); } for (int i = 0; i < initSQL.length; i++) { try { System.out.println(" init " + initSQL[i]); processor.processUpdate(initSQL[i], null); } catch (SQLException e) { throw new HammurapiException(e); } } }
public void saveLanguageElement(final StringVariable strVar) { System.out.println("** saveLanguageElement " + strVar.langElement.toString()); final boolean[] ret = {false}; SQLProcessor processor = getProcessor((SourceMarker) strVar.langElement); if (processor != null) { try { String templangElementName = "<unresolved>"; if (strVar.langElement instanceof VariableDefinition) { templangElementName = ((VariableDefinition) strVar.langElement).getName(); } else if (strVar.langElement instanceof Parameter) { templangElementName = ((Parameter) strVar.langElement).getName(); } final String langElementName = templangElementName; // System.out.println(langElementName + " :- "+ currentStringValue ); // check for String Only ! // -- is entry already available? processor.processSelect( "SELECT 'variable', SOURCE, LINE, COL, VAR_NAME, VAR_VALUE , CLASS_NAME, CLASS_FCN FROM " + varTableName + " WHERE VAR_NAME = ? " + "AND CLASS_NAME = ?" + "AND CLASS_FCN = ?", (new Parameterizer() { public void parameterize(PreparedStatement ps) throws SQLException { ps.setString(1, langElementName); ps.setString(2, strVar.className); ps.setString(3, strVar.classFcn); } }), new RowProcessor() { public boolean process(ResultSet rs) throws SQLException { try { String tmpStr = rs.getString("VAR_NAME"); // System.out.println (" KKKKKKK " + tmpStr + " --"+ currentStringValue ); ret[0] = langElementName.equals(tmpStr); return true; } catch (Exception e) { throw new HammurapiRuntimeException(e); } } }); // -- update entry if (ret[0]) { // System.out.println (" KKKKKKK UPDATE" ); processor.processUpdate( "UPDATE " + varTableName + " SET " + " VAR_VALUE = ?" + " WHERE VAR_NAME = ? " + "AND CLASS_NAME = ?" + "AND CLASS_FCN = ?", new Parameterizer() { public void parameterize(PreparedStatement ps) throws SQLException { ps.setString(1, strVar.varValue.toString()); ps.setString(2, langElementName); ps.setString(3, strVar.className); ps.setString(4, strVar.classFcn); } }); } else { // System.out.println (" KKKKKKK INSERT" ); // -- insert entry processor.processUpdate( "INSERT INTO " + varTableName + " (VAR_NAME, VAR_VALUE, SOURCE, LINE, COL, CLASS_NAME, CLASS_FCN) " + "VALUES (?,?,?,?,?,?,?)", new Parameterizer() { public void parameterize(PreparedStatement ps) throws SQLException { ps.setString(1, langElementName); ps.setString(2, strVar.varValue.toString()); SourceMarker sourceMarker = (SourceMarker) strVar.langElement; ps.setString(3, sourceMarker.getSourceURL()); ps.setInt(4, sourceMarker.getLine()); ps.setInt(5, sourceMarker.getColumn()); ps.setString(6, strVar.className); ps.setString(7, strVar.classFcn); } }); } // fi } catch (SQLException e) { context.warn((SourceMarker) strVar.langElement, e); } } }