public class mianClass {
public static void main(String[] args) {
/*
JDBC
Java DataBase Connectivity
*/
JdbcConnect jc = new JdbcConnect();
jc.getConnection();
}
}
//출력
//Driver Loading Success
//Oracle Connection Success
public class JdbcConnect {
public JdbcConnect() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver Loading Success");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public Connection getConnection() { //jdbc에 있는 object를 return해줌
Connection conn = null; //return해줄 conn생성
try {
conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.7.40:1521:xe",
"hr", "hr"); // (db가서 url가져옴, , )
System.out.println("Oracle Connection Success");
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
}
'JDBC' 카테고리의 다른 글
Delete (0) | 2020.06.30 |
---|---|
Select (0) | 2020.06.30 |
Select 한개의 데이터 (0) | 2020.06.30 |
Update (0) | 2020.06.30 |
INSERT (기본 -> DBclose 수정) (0) | 2020.06.30 |