e.printStackTrace();
if(log.isErrorEnabled()) { log.error("Exception: ", e); }
  static String getNextId(String queryName, String prefix) {    DecimalFormat format = new DecimalFormat(prefix + "0000");    Map substitutions = new HashMap();    substitutions.put(":max_id_pattern", prefix + "____");    String id = format.format(1); // Default    Logger qLog = CSMART.createLogger("queries");    try {      Connection dbConnection = DBUtils.getConnection(QUERY_FILE);      Statement stmt = dbConnection.createStatement();      try {	if(dbp==null)	  dbp = DBProperties.readQueryFile(QUERY_FILE);	String query = dbp.getQuery(queryName, substitutions);	if (qLog.isDebugEnabled()) {	  qLog.debug("getNextId: "+query);	}	ResultSet rs = stmt.executeQuery(query);	try {	  if (rs.next()) {	    String maxId = rs.getString(1);	    if (maxId != null) {	      int n = format.parse(maxId).intValue();	      if (qLog.isDebugEnabled()) {		qLog.debug("getNextId: n="+n+", maxId ="+maxId);	      }	      id = format.format(n + 1);	      if (qLog.isDebugEnabled()) {		 qLog.debug("getNextId: id="+id);	      }	    }	  }	} finally {	  rs.close();	}      } finally {	stmt.close();      }    } catch (Exception e) {      e.printStackTrace();      // Ignore exceptions and use default    }    return id;  }