package main;
import db.jdbctest;
public class mainClass {
public static void main(String[] args) {
/*
JDBC
java database connectivity
*/
jdbctest jt = new jdbctest();
jt.getConnection();
}
}
mainClass.java
package db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class jdbctest {
public jdbctest() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
// 이 클래스가 존재를 하냐 안하냐 할수 있게 해준다.
System.out.println("Driver Loding Success!!");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public Connection getConnection() {
Connection conn = null;
try {
conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:xe", "hr", "hr");
System.out.println("DB Connection Success!!");
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
}
jdbctest.java
'IT > JDBC' 카테고리의 다른 글
DB연결 데이터 입출력(2) (0) | 2020.03.25 |
---|---|
DB연결 데이터 입출력(1) (0) | 2020.03.15 |
댓글