package DB;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBClose {
public static void close(Statement stmt, Connection conn, ResultSet rs) {
try {
if(stmt != null) {
stmt.close();
}
if(conn != null) {
conn.close();
}
if(rs != null) {
rs.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
package DB;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBConnection {
public static void initConnect() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver Loading Success!!");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public static Connection makeConnection() {
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;
}
}