code: public static String getApplicationName()
      {
          if (APPLICATION_NAME == null)
          {
              String name = System.getProperty(APPLICATION_NAME_KEY);
              if (name == null)
              {
                  name = "JDBC";
                  ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
                  ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(threadMXBean.getAllThreadIds());
                  long mainThreadNumber = -1;
                  for(int i=0;i<threadInfos.length;i++)
                  {
                      if (threadInfos[i] != null && threadInfos[i].getThreadName().equals("main"))
                      {
                          mainThreadNumber = threadInfos[i].getThreadId();
                          break;
                      }
                  }
                  if (mainThreadNumber >= 0)
                  {
                      ThreadInfo threadInfo = threadMXBean.getThreadInfo(mainThreadNumber, Integer.MAX_VALUE);
                      StackTraceElement[] stackTrace = threadInfo.getStackTrace();
                      if (stackTrace.length > 0)
                      {
                          String cname = stackTrace[stackTrace.length - 1].getClassName();
                          name = cname.substring(Math.max(0, cname.lastIndexOf(".") + 1), cname.length());
                      }
                  }
                  if (name.equals("ApplicationRunner"))
                  {
                      name = System.getProperty("applicationrunner.properties");
                  }
              }
              if (name.length() > 30)
              {
                  name = name.substring(0, 30);
              }
              APPLICATION_NAME = name;
          }
          return APPLICATION_NAME;
      }
docs: todo:move this method to utility class if this if functionality is needed somewhere else.