Class SqlExecutor

java.lang.Object
com.altibase.document.installer.SqlExecutor

public class SqlExecutor extends Object
SQL 파일을 로드하고 실행하는 클래스 클래스로더를 통해 JAR 내부의 SQL 파일을 읽음
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    executeSql(Connection aConnection, String aSqlContent)
    SQL 문장 실행 명령 구분자(/ 또는 ;)를 기준으로 개별 명령 실행
    static void
    executeSqlFile(Connection aConnection, String aResourcePath, Map<String,String> aVariables)
    클래스로더에서 SQL 파일을 읽어 변수를 치환한 후 실행
    static void
    executeSqlFile(Connection aConnection, String aResourcePath, Map<String,String> aVariables, Class<?> aClassForLoader)
    클래스로더에서 SQL 파일을 읽어 변수를 치환한 후 실행 (클래스로더 지정) 멀티모듈 프로젝트에서 특정 모듈의 리소스를 로드할 때 사용한다.
    static String
    loadSqlFile(String aResourcePath)
    SQL 파일을 로드 (classpath 기반) JAR 내부 또는 개발 중 src/main/resources/sql/ 폴더에서 파일을 찾음 프로덕션(JAR 실행)과 테스트(gradle test) 환경 모두 지원
    static String
    loadSqlFile(String aResourcePath, Class<?> aClassForLoader)
    SQL 파일을 로드 (classpath 기반, 클래스로더 지정) 멀티모듈 프로젝트에서 특정 모듈의 리소스를 로드할 때 사용

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • executeSqlFile

      public static void executeSqlFile(Connection aConnection, String aResourcePath, Map<String,String> aVariables) throws SQLException, IOException
      클래스로더에서 SQL 파일을 읽어 변수를 치환한 후 실행
      Throws:
      SQLException
      IOException
    • executeSqlFile

      public static void executeSqlFile(Connection aConnection, String aResourcePath, Map<String,String> aVariables, Class<?> aClassForLoader) throws SQLException, IOException
      클래스로더에서 SQL 파일을 읽어 변수를 치환한 후 실행 (클래스로더 지정) 멀티모듈 프로젝트에서 특정 모듈의 리소스를 로드할 때 사용한다.

      이 메서드는 Multi-Module 환경(예: document-access-rest에서 document-access-java의 리소스 접근)에서 현재 스레드의 ContextClassLoader가 아닌, 리소스를 소유한 모듈의 ClassLoader를 명시적으로 사용하여 SQL 파일을 정확히 찾기 위해 추가되었다.

      Parameters:
      aConnection - DB 연결
      aResourcePath - SQL 파일 경로
      aVariables - 치환할 변수 맵
      aClassForLoader - 리소스를 로드할 클래스 (이 클래스의 ClassLoader 사용)
      Throws:
      SQLException
      IOException
    • loadSqlFile

      public static String loadSqlFile(String aResourcePath) throws IOException
      SQL 파일을 로드 (classpath 기반) JAR 내부 또는 개발 중 src/main/resources/sql/ 폴더에서 파일을 찾음 프로덕션(JAR 실행)과 테스트(gradle test) 환경 모두 지원
      Throws:
      IOException
    • loadSqlFile

      public static String loadSqlFile(String aResourcePath, Class<?> aClassForLoader) throws IOException
      SQL 파일을 로드 (classpath 기반, 클래스로더 지정) 멀티모듈 프로젝트에서 특정 모듈의 리소스를 로드할 때 사용
      Parameters:
      aResourcePath - SQL 파일 경로 (예: "create_table.sql")
      aClassForLoader - 리소스를 로드할 클래스 (해당 클래스의 클래스로더 사용)
      Throws:
      IOException
    • executeSql

      public static void executeSql(Connection aConnection, String aSqlContent) throws SQLException
      SQL 문장 실행 명령 구분자(/ 또는 ;)를 기준으로 개별 명령 실행
      Throws:
      SQLException