Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 97f3924b48 | |||
| 9e7d1e06ae | |||
| a5533aeb77 | |||
| 0e5ccfe379 | |||
| 329c222f56 | |||
| 56130f34b2 |
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
|
||||||
<classpathentry kind="lib" path="lib/mysql-connector-java-8.0.23.jar"/>
|
|
||||||
<classpathentry kind="lib" path="実行例/DAO_Simple.jar"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
|
||||||
</classpath>
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
/bin/
|
|
||||||
23
.project
23
.project
@@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>em-jdbc</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
|
|
||||||
<classpathentry kind="src" path=""/>
|
|
||||||
<classpathentry kind="output" path=""/>
|
|
||||||
</classpath>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
org.eclipse.wst.jsdt.launching.JRE_CONTAINER
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Global
|
|
||||||
@@ -53,7 +53,12 @@ public class EmployeeDAO {
|
|||||||
List<EmployeeDTO> rtnList = new ArrayList<>();
|
List<EmployeeDTO> rtnList = new ArrayList<>();
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append(" SELECT ");
|
sql.append(" SELECT ");
|
||||||
sql.append(" " + "*");
|
sql.append(" " + ID_EMPLOYEE + ",");
|
||||||
|
sql.append(" " + NM_EMPLOYEE + ",");
|
||||||
|
sql.append(" " + KN_EMPLOYEE + ",");
|
||||||
|
sql.append(" " + MAIL_ADDRESS + ",");
|
||||||
|
sql.append(" " + PASSWORD + ",");
|
||||||
|
sql.append(" " + ID_DEPARTMENT);
|
||||||
sql.append(" FROM ");
|
sql.append(" FROM ");
|
||||||
sql.append(" " + TBL_NAME);
|
sql.append(" " + TBL_NAME);
|
||||||
try {
|
try {
|
||||||
@@ -61,14 +66,15 @@ public class EmployeeDAO {
|
|||||||
this.stmt = con.prepareStatement(sql.toString());
|
this.stmt = con.prepareStatement(sql.toString());
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
//インスタンス生成
|
|
||||||
EmployeeDTO dto = new EmployeeDTO();
|
EmployeeDTO dto = new EmployeeDTO();
|
||||||
dto.setId_employee(rs.getInt("id_employee"));
|
dto.setIdEmployee(rs.getInt(ID_EMPLOYEE));
|
||||||
dto.setNm_employee(rs.getString("nm_employee"));
|
dto.setNmEmployee(rs.getString(NM_EMPLOYEE));
|
||||||
dto.setKn_employee(rs.getString("kn_employee"));
|
dto.setKnEmployee(rs.getString(KN_EMPLOYEE));
|
||||||
dto.setMail_address(rs.getString("mail_address"));
|
dto.setMailAddress(rs.getString(MAIL_ADDRESS));
|
||||||
dto.setPassword(rs.getString("password"));
|
dto.setPassword(rs.getString(PASSWORD));
|
||||||
dto.setId_department(rs.getInt("id_department"));
|
dto.setIdDepartment(rs.getInt(ID_DEPARTMENT));
|
||||||
|
|
||||||
|
// dto ကို List ထဲသို့ ထည့်ရပါမည်
|
||||||
rtnList.add(dto);
|
rtnList.add(dto);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -77,4 +83,117 @@ public class EmployeeDAO {
|
|||||||
return rtnList;
|
return rtnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//use selectById make the method
|
||||||
|
public List<EmployeeDTO> selectById(int empId) throws SQLException, ClassNotFoundException {
|
||||||
|
//calling to DTO and new inout array
|
||||||
|
List<EmployeeDTO> rtnList = new ArrayList<>();
|
||||||
|
//(StringBuilder) ကို သုံးခြင်းသည် Code များကို ဖတ်ရလွယ်ကူစေရန်၊ ပြင်ဆင်ရလွယ်ကူစေရန်
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
//append မသုံးရင်စာကြောင်းပိုရှဉ္လို့ append နဲံရေး
|
||||||
|
sql.append(" SELECT ");
|
||||||
|
sql.append(" " + ID_EMPLOYEE + ",");
|
||||||
|
sql.append(" " + NM_EMPLOYEE + ",");
|
||||||
|
sql.append(" " + KN_EMPLOYEE + ",");
|
||||||
|
sql.append(" " + MAIL_ADDRESS + ",");
|
||||||
|
sql.append(" " + PASSWORD + ",");
|
||||||
|
sql.append(" " + ID_DEPARTMENT);
|
||||||
|
sql.append(" FROM ");
|
||||||
|
sql.append(" " + TBL_NAME);
|
||||||
|
sql.append(" WHERE ");
|
||||||
|
sql.append(" " + ID_EMPLOYEE + " = ? ");
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.stmt = con.prepareStatement(sql.toString());
|
||||||
|
this.stmt.setInt(1, empId);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
while (rs.next()) {
|
||||||
|
EmployeeDTO dto = new EmployeeDTO();
|
||||||
|
dto.setIdEmployee(rs.getInt(ID_EMPLOYEE));
|
||||||
|
dto.setNmEmployee(rs.getString(NM_EMPLOYEE));
|
||||||
|
dto.setKnEmployee(rs.getString(KN_EMPLOYEE));
|
||||||
|
dto.setMailAddress(rs.getString(MAIL_ADDRESS));
|
||||||
|
dto.setPassword(rs.getString(PASSWORD));
|
||||||
|
dto.setIdDepartment(rs.getInt(ID_DEPARTMENT));
|
||||||
|
|
||||||
|
rtnList.add(dto);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
DbUtil.closeStatement(this.stmt);
|
||||||
|
}
|
||||||
|
return rtnList;
|
||||||
|
}
|
||||||
|
//Delete method
|
||||||
|
public void empDelete(int empId) throws ClassNotFoundException, SQLException {
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append(" DELETE FROM ");
|
||||||
|
sql.append(" " + TBL_NAME);
|
||||||
|
sql.append(" WHERE ");
|
||||||
|
sql.append(" " + ID_EMPLOYEE + " = ? ");
|
||||||
|
//for check
|
||||||
|
try {
|
||||||
|
this.stmt = con.prepareStatement(sql.toString());
|
||||||
|
this.stmt.setInt(1, empId);
|
||||||
|
this.stmt.executeUpdate();
|
||||||
|
} finally {
|
||||||
|
DbUtil.closeStatement(this.stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public void empInsert (String nmemp, String knname,String mail, String pw, int deptId) throws ClassNotFoundException, SQLException{
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("INSERT INTO");
|
||||||
|
sql.append(" " + TBL_NAME);
|
||||||
|
sql.append(" ( ");
|
||||||
|
|
||||||
|
sql.append(" " + NM_EMPLOYEE + ",");
|
||||||
|
sql.append(" " + KN_EMPLOYEE + ",");
|
||||||
|
sql.append(" " + MAIL_ADDRESS + ",");
|
||||||
|
sql.append(" " + PASSWORD + ",");
|
||||||
|
sql.append(" " + ID_DEPARTMENT);
|
||||||
|
sql.append(" ) ");
|
||||||
|
sql.append(" VALUES (?, ?, ?, ?, ?) ");
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.stmt = con.prepareStatement(sql.toString());
|
||||||
|
this.stmt.setString(1, nmemp);
|
||||||
|
this.stmt.setString(2, knname);
|
||||||
|
this.stmt.setString(3, mail);
|
||||||
|
this.stmt.setString(4, pw);
|
||||||
|
this.stmt.setInt(5, deptId);
|
||||||
|
|
||||||
|
this.stmt.executeUpdate();
|
||||||
|
} finally {
|
||||||
|
DbUtil.closeStatement(this.stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public void empUpdate (String nmemp, String knname,String mail, String pw, int deptId,int empId) throws ClassNotFoundException, SQLException{
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("UPDATE ");
|
||||||
|
sql.append(" " + TBL_NAME);
|
||||||
|
sql.append(" SET ");
|
||||||
|
|
||||||
|
sql.append(" " + NM_EMPLOYEE + " = ?, ");
|
||||||
|
sql.append(" " + KN_EMPLOYEE + " = ?, ");
|
||||||
|
sql.append(" " + MAIL_ADDRESS + " = ?, ");
|
||||||
|
sql.append(" " + PASSWORD + " = ?, ");
|
||||||
|
sql.append(" " + ID_DEPARTMENT + " = ? ");
|
||||||
|
sql.append(" WHERE ");
|
||||||
|
sql.append(" " + ID_EMPLOYEE + " = ? ");
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.stmt = con.prepareStatement(sql.toString());
|
||||||
|
this.stmt.setString(1, nmemp);
|
||||||
|
this.stmt.setString(2, knname);
|
||||||
|
this.stmt.setString(3, mail);
|
||||||
|
this.stmt.setString(4, pw);
|
||||||
|
this.stmt.setInt(5, deptId);
|
||||||
|
this.stmt.setInt(6, empId);
|
||||||
|
|
||||||
|
this.stmt.executeUpdate();
|
||||||
|
} finally {
|
||||||
|
DbUtil.closeStatement(this.stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package com.rhizome.example.dto;
|
|
||||||
|
|
||||||
public class EmployeeDTO {
|
|
||||||
//フィールド宣言
|
|
||||||
private Integer id_employee;//社員ID
|
|
||||||
private String nm_employee;//社員名
|
|
||||||
private String kn_employee;//社員名カナ
|
|
||||||
private String mail_address;//メールアドレス
|
|
||||||
private String password;//パスワード
|
|
||||||
private Integer id_department;//部署ID
|
|
||||||
|
|
||||||
//getter/setter
|
|
||||||
public Integer getId_employee() {
|
|
||||||
return id_employee;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId_employee(Integer id_employee) {
|
|
||||||
this.id_employee = id_employee;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNm_employee() {
|
|
||||||
return nm_employee;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNm_employee(String nm_employee) {
|
|
||||||
this.nm_employee = nm_employee;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKn_employee() {
|
|
||||||
return kn_employee;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKn_employee(String kn_employee) {
|
|
||||||
this.kn_employee = kn_employee;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMail_address() {
|
|
||||||
return mail_address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMail_address(String mail_address) {
|
|
||||||
this.mail_address = mail_address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId_department() {
|
|
||||||
return id_department;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId_department(Integer id_department) {
|
|
||||||
this.id_department = id_department;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -54,10 +54,13 @@ public class Main {
|
|||||||
empSelect();
|
empSelect();
|
||||||
break;
|
break;
|
||||||
case "2":
|
case "2":
|
||||||
|
empInsert();
|
||||||
break;
|
break;
|
||||||
case "3":
|
case "3":
|
||||||
|
empUpdate();
|
||||||
break;
|
break;
|
||||||
case "4":
|
case "4":
|
||||||
|
empDelete();
|
||||||
break;
|
break;
|
||||||
case "9":
|
case "9":
|
||||||
return;
|
return;
|
||||||
@@ -70,6 +73,67 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void empUpdate() throws ClassNotFoundException, SQLException{
|
||||||
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
|
Connection con = DbUtil.getConnection();
|
||||||
|
EmployeeDAO empDao = new EmployeeDAO(con);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// ID ရိုက်ထည့်ခိုင်းခြင်း
|
||||||
|
String strId = inputCheck("ID", true);
|
||||||
|
int id = Integer.parseInt(strId);
|
||||||
|
|
||||||
|
// ID ရှိမရှိ စစ်ဆေးခြင်း (selectById ကို သုံးပါ)
|
||||||
|
List<EmployeeDTO> empList = empDao.selectById(id);
|
||||||
|
if (empList.isEmpty()) {
|
||||||
|
System.out.println("入力された値で情報がみつかりませんでした");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// အချက်အလက် အသစ်များ တောင်းခံခြင်း
|
||||||
|
String name = inputCheck("社員名", false);
|
||||||
|
String kana = inputCheck("フリガナ", false);
|
||||||
|
String mail = inputCheck("メールアドレス", false);
|
||||||
|
String pass = inputCheck("パスワード", false);
|
||||||
|
|
||||||
|
String strDeptId = inputCheck("部署ID", true);
|
||||||
|
int deptId = Integer.parseInt(strDeptId);
|
||||||
|
|
||||||
|
// DB ထဲသို့ ပြင်ဆင်ချက် ထည့်သွင်းခြင်း
|
||||||
|
empDao.empUpdate(name, kana, mail, pass, deptId,id);
|
||||||
|
System.out.println("更新が完了しました");
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
DbUtil.closeConnection(empDao.con);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void empInsert() throws ClassNotFoundException, SQLException {
|
||||||
|
Connection con = DbUtil.getConnection();
|
||||||
|
EmployeeDAO empDao = new EmployeeDAO(con);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// အချက်အလက်များ အသီးသီး တောင်းခံခြင်း (inputCheck ကို သုံးပါ)
|
||||||
|
String name = inputCheck("社員名", false);
|
||||||
|
String kana = inputCheck("フリガナ", false);
|
||||||
|
String mail = inputCheck("メールアドレス", false);
|
||||||
|
String pass = inputCheck("パスワード", false);
|
||||||
|
|
||||||
|
// 部署ID အတွက် Numerical Check ဖြစ်သည့် true ထည့်ပါမည်
|
||||||
|
String strDeptId = inputCheck("部署ID", true);
|
||||||
|
int deptId = Integer.parseInt(strDeptId);
|
||||||
|
|
||||||
|
// DB ထဲသို့ ထည့်သွင်းခြင်း
|
||||||
|
empDao.empInsert(name, kana, mail, pass, deptId);
|
||||||
|
System.out.println("登録が完了しました");
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
DbUtil.closeConnection(empDao.con);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社員テーブルから情報を検索する
|
* 社員テーブルから情報を検索する
|
||||||
*
|
*
|
||||||
@@ -77,6 +141,7 @@ public class Main {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public static void empSelect() throws ClassNotFoundException, SQLException {
|
public static void empSelect() throws ClassNotFoundException, SQLException {
|
||||||
|
//List<String> empList = new ArrayList<>();
|
||||||
List<EmployeeDTO> empList = new ArrayList<>();
|
List<EmployeeDTO> empList = new ArrayList<>();
|
||||||
Connection con = DbUtil.getConnection();
|
Connection con = DbUtil.getConnection();
|
||||||
EmployeeDAO empDao = new EmployeeDAO(con);
|
EmployeeDAO empDao = new EmployeeDAO(con);
|
||||||
@@ -85,13 +150,64 @@ public class Main {
|
|||||||
try {
|
try {
|
||||||
switch (select) {
|
switch (select) {
|
||||||
case "1":
|
case "1":
|
||||||
|
//empList = empDao.selectAll();
|
||||||
empList = empDao.selectAll();
|
empList = empDao.selectAll();
|
||||||
break;
|
break;
|
||||||
|
case "2":
|
||||||
|
// inputCheck 方法ကို သုံးပြီး ID ရိုက်ခိုင်းပါ (数値 check အတွက် true ထည့်ပါ)
|
||||||
|
String strId = inputCheck("ID", true);
|
||||||
|
int id = Integer.parseInt(strId);
|
||||||
|
empList = empDao.selectById(id);
|
||||||
|
;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ရှာဖွေတွေ့ရှိခြင်း မရှိပါက
|
||||||
|
if (empList.isEmpty()) {
|
||||||
|
System.out.println("入力された値で情報がみつかりませんでした");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (EmployeeDTO emp : empList) {
|
for (EmployeeDTO emp : empList) {
|
||||||
System.out.println(emp);
|
//for (String emp : empList) {
|
||||||
|
//System.out.println(emp);
|
||||||
|
System.out.println(emp.getIdEmployee() + "\t" +
|
||||||
|
emp.getNmEmployee() + "\t" +
|
||||||
|
emp.getKnEmployee() + "\t" +
|
||||||
|
emp.getMailAddress() + "\t" +
|
||||||
|
emp.getPassword() + "\t" +
|
||||||
|
emp.getIdDepartment());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
DbUtil.closeConnection(empDao.con);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void empDelete() throws ClassNotFoundException, SQLException {
|
||||||
|
Connection con = DbUtil.getConnection();
|
||||||
|
EmployeeDAO empDao = new EmployeeDAO(con);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// ID ရိုက်ထည့်ခိုင်းခြင်း (inputCheck ကို သုံးပါ)
|
||||||
|
String strId = inputCheck("ID", true);
|
||||||
|
int id = Integer.parseInt(strId);
|
||||||
|
//System.out.println("IDを入力してください");
|
||||||
|
|
||||||
|
// ID ရှိမရှိ စစ်ဆေးခြင်း (selectById ကို သုံးပါ)
|
||||||
|
List<EmployeeDTO> empList = empDao.selectById(id);
|
||||||
|
if (empList.isEmpty()) {
|
||||||
|
System.out.println("入力された値で情報がみつかりませんでした");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ဖျက်ရန် အတည်ပြုချက် (Confirmation) တောင်းခြင်း
|
||||||
|
System.out.println("指定されたIDの情報を削除します? Y/y");
|
||||||
|
String confirm = sc.nextLine();
|
||||||
|
if ("Y".equalsIgnoreCase(confirm)) {
|
||||||
|
empDao.empDelete(id);
|
||||||
|
System.out.println("削除が完了しました");
|
||||||
}
|
}
|
||||||
}finally {
|
}finally {
|
||||||
DbUtil.closeConnection(empDao.con);
|
DbUtil.closeConnection(empDao.con);
|
||||||
@@ -147,4 +263,7 @@ public class Main {
|
|||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,14 +42,19 @@ public class DbUtil {
|
|||||||
* 例外 :ClassNotFoundException, SQLException
|
* 例外 :ClassNotFoundException, SQLException
|
||||||
* 処理 :JDBCドライバを読み込み後、DB接続する。
|
* 処理 :JDBCドライバを読み込み後、DB接続する。
|
||||||
* 生成されたConnectionを返却する
|
* 生成されたConnectionを返却する
|
||||||
* ※Connection生成には上記の定数を活用してください
|
* ※Connection生成には上記の定数を活用してくださ
|
||||||
*/
|
*/
|
||||||
public static Connection getConnection() throws SQLException {
|
|
||||||
//データベースへの接続
|
public static Connection getConnection() throws ClassNotFoundException, SQLException {
|
||||||
|
//connection is null or not null and create new
|
||||||
|
if (con == null || con.isClosed()) {
|
||||||
|
Class.forName(DB_DRIVER);
|
||||||
con = DriverManager.getConnection(DB_URL, DB_USER, DB_PASS);
|
con = DriverManager.getConnection(DB_URL, DB_USER, DB_PASS);
|
||||||
|
}
|
||||||
return con;
|
return con;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO 以下の仕様でメソッドを作成してください。
|
* TODO 以下の仕様でメソッドを作成してください。
|
||||||
*
|
*
|
||||||
@@ -60,10 +65,11 @@ public class DbUtil {
|
|||||||
* 処理 :引数のDBステートメントがnullでない場合、そのDBステートメントをクローズする
|
* 処理 :引数のDBステートメントがnullでない場合、そのDBステートメントをクローズする
|
||||||
*/
|
*/
|
||||||
public static void closeStatement(PreparedStatement stmt) throws SQLException {
|
public static void closeStatement(PreparedStatement stmt) throws SQLException {
|
||||||
//nullチェック
|
|
||||||
if (stmt != null) {
|
if (stmt != null) {
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -76,10 +82,10 @@ public class DbUtil {
|
|||||||
* 処理 :引数のコネクションがnullでない場合、そのコネクションを切断する
|
* 処理 :引数のコネクションがnullでない場合、そのコネクションを切断する
|
||||||
*/
|
*/
|
||||||
public static void closeConnection(Connection con) throws SQLException {
|
public static void closeConnection(Connection con) throws SQLException {
|
||||||
//nullチェック
|
|
||||||
if(con != null) {
|
if(con != null) {
|
||||||
con.close();
|
con.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user