Package com.altibase.document.installer
Class SqlExecutor
java.lang.Object
com.altibase.document.installer.SqlExecutor
SQL 파일을 로드하고 실행하는 클래스
클래스로더를 통해 JAR 내부의 SQL 파일을 읽음
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidexecuteSql(Connection aConnection, String aSqlContent) SQL 문장 실행 명령 구분자(/ 또는 ;)를 기준으로 개별 명령 실행static voidexecuteSqlFile(Connection aConnection, String aResourcePath, Map<String, String> aVariables) 클래스로더에서 SQL 파일을 읽어 변수를 치환한 후 실행static voidexecuteSqlFile(Connection aConnection, String aResourcePath, Map<String, String> aVariables, Class<?> aClassForLoader) 클래스로더에서 SQL 파일을 읽어 변수를 치환한 후 실행 (클래스로더 지정) 멀티모듈 프로젝트에서 특정 모듈의 리소스를 로드할 때 사용한다.static StringloadSqlFile(String aResourcePath) SQL 파일을 로드 (classpath 기반) JAR 내부 또는 개발 중 src/main/resources/sql/ 폴더에서 파일을 찾음 프로덕션(JAR 실행)과 테스트(gradle test) 환경 모두 지원static StringloadSqlFile(String aResourcePath, Class<?> aClassForLoader) SQL 파일을 로드 (classpath 기반, 클래스로더 지정) 멀티모듈 프로젝트에서 특정 모듈의 리소스를 로드할 때 사용
-
Method Details
-
executeSqlFile
public static void executeSqlFile(Connection aConnection, String aResourcePath, Map<String, String> aVariables) throws SQLException, IOException클래스로더에서 SQL 파일을 읽어 변수를 치환한 후 실행- Throws:
SQLExceptionIOException
-
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:
SQLExceptionIOException
-
loadSqlFile
SQL 파일을 로드 (classpath 기반) JAR 내부 또는 개발 중 src/main/resources/sql/ 폴더에서 파일을 찾음 프로덕션(JAR 실행)과 테스트(gradle test) 환경 모두 지원- Throws:
IOException
-
loadSqlFile
SQL 파일을 로드 (classpath 기반, 클래스로더 지정) 멀티모듈 프로젝트에서 특정 모듈의 리소스를 로드할 때 사용- Parameters:
aResourcePath- SQL 파일 경로 (예: "create_table.sql")aClassForLoader- 리소스를 로드할 클래스 (해당 클래스의 클래스로더 사용)- Throws:
IOException
-
executeSql
SQL 문장 실행 명령 구분자(/ 또는 ;)를 기준으로 개별 명령 실행- Throws:
SQLException
-