Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cb48440b0 |
@@ -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>
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1 @@
|
|||||||
/bin/
|
/.metadata/
|
||||||
|
|||||||
12
.project
12
.project
@@ -5,19 +5,7 @@
|
|||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
|
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</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
|
|
||||||
6
src/.classpath
Normal file
6
src/.classpath
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="src" path=""/>
|
||||||
|
<classpathentry kind="output" path=""/>
|
||||||
|
</classpath>
|
||||||
17
src/.project
Normal file
17
src/.project
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>src</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
1
src/com/rhizome/example/dao/.gitignore
vendored
Normal file
1
src/com/rhizome/example/dao/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/EmployeeDAO.class
|
||||||
@@ -13,7 +13,6 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.rhizome.example.dto.EmployeeDTO;
|
|
||||||
import com.rhizome.example.util.DbUtil;
|
import com.rhizome.example.util.DbUtil;
|
||||||
|
|
||||||
public class EmployeeDAO {
|
public class EmployeeDAO {
|
||||||
@@ -49,8 +48,8 @@ public class EmployeeDAO {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
public List<EmployeeDTO> selectAll() throws SQLException, ClassNotFoundException {
|
public List<String> selectAll() throws SQLException, ClassNotFoundException {
|
||||||
List<EmployeeDTO> rtnList = new ArrayList<>();
|
List<String> rtnList = new ArrayList<>();
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append(" SELECT ");
|
sql.append(" SELECT ");
|
||||||
sql.append(" " + "*");
|
sql.append(" " + "*");
|
||||||
@@ -61,15 +60,7 @@ 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()) {
|
||||||
//インスタンス生成
|
rtnList.add(rs.getString(NM_EMPLOYEE));
|
||||||
EmployeeDTO dto = new EmployeeDTO();
|
|
||||||
dto.setId_employee(rs.getInt("id_employee"));
|
|
||||||
dto.setNm_employee(rs.getString("nm_employee"));
|
|
||||||
dto.setKn_employee(rs.getString("kn_employee"));
|
|
||||||
dto.setMail_address(rs.getString("mail_address"));
|
|
||||||
dto.setPassword(rs.getString("password"));
|
|
||||||
dto.setId_department(rs.getInt("id_department"));
|
|
||||||
rtnList.add(dto);
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
DbUtil.closeStatement(this.stmt);
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
1
src/com/rhizome/example/main/.gitignore
vendored
Normal file
1
src/com/rhizome/example/main/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/Main.class
|
||||||
@@ -7,7 +7,6 @@ import java.util.List;
|
|||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import com.rhizome.example.dao.EmployeeDAO;
|
import com.rhizome.example.dao.EmployeeDAO;
|
||||||
import com.rhizome.example.dto.EmployeeDTO;
|
|
||||||
import com.rhizome.example.util.DbUtil;
|
import com.rhizome.example.util.DbUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,7 +76,7 @@ public class Main {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public static void empSelect() throws ClassNotFoundException, SQLException {
|
public static void empSelect() throws ClassNotFoundException, SQLException {
|
||||||
List<EmployeeDTO> empList = new ArrayList<>();
|
List<String> empList = new ArrayList<>();
|
||||||
Connection con = DbUtil.getConnection();
|
Connection con = DbUtil.getConnection();
|
||||||
EmployeeDAO empDao = new EmployeeDAO(con);
|
EmployeeDAO empDao = new EmployeeDAO(con);
|
||||||
System.out.println("1:全検索 2:条件検索 それ以外:戻る");
|
System.out.println("1:全検索 2:条件検索 それ以外:戻る");
|
||||||
@@ -90,7 +89,7 @@ public class Main {
|
|||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (EmployeeDTO emp : empList) {
|
for (String emp : empList) {
|
||||||
System.out.println(emp);
|
System.out.println(emp);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
1
src/com/rhizome/example/util/.gitignore
vendored
Normal file
1
src/com/rhizome/example/util/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/DbUtil.class
|
||||||
Reference in New Issue
Block a user