드라이버 로드
드라이버 로드
Class.forName("oracle.jdbc.OracleDriver");Class.forName()
package test;
public class ExampleObject {
static {
System.out.println("static 실행");
}
public ExampleObject() {
System.out.println("생성자 실행");
}
}
package test;
import java.lang.reflect.InvocationTargetException;
public class ExampleApplication {
public static void main(String[] args) throws Exception {
Object obj = Class.forName("test.ExampleObject");
Class<ExampleObject> clazz = (Class<ExampleObject>) obj;
ExampleObject ex = clazz.getDeclaredConstructor().newInstance();
//ExampleObject ex = new ExampleObject();
}
}
Last updated