1段階目終了しました

This commit is contained in:
2026-09-30 11:26:04 +09:00
parent 371e68841a
commit bb5df7baad
8 changed files with 61 additions and 4 deletions

8
.classpath Normal file
View File

@@ -0,0 +1,8 @@
<?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 Normal file
View File

@@ -0,0 +1 @@
/bin/

23
.project Normal file
View File

@@ -0,0 +1,23 @@
<?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>

7
.settings/.jsdtscope Normal file
View File

@@ -0,0 +1,7 @@
<?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>

View File

@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.JRE_CONTAINER

View File

@@ -0,0 +1 @@
Global

View File

@@ -63,7 +63,7 @@ public class EmployeeDAO {
rtnList.add(rs.getString(NM_EMPLOYEE));
}
} finally {
DbUtil.closeStatement(this.stmt);
DbUtil.closestatement(this.stmt);
}
return rtnList;
}

View File

@@ -1,6 +1,9 @@
package com.rhizome.example.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class DbUtil {
// 定数定義(共通)
@@ -41,7 +44,11 @@ public class DbUtil {
* 生成されたConnectionを返却する
* ※Connection生成には上記の定数を活用してください
*/
public static Connection getConnection() throws SQLException {
//データベースの接続
con = DriverManager.getConnection(DB_URL, DB_USER, DB_PASS);
return con;
}
/*
* TODO 以下の仕様でメソッドを作成してください。
@@ -53,6 +60,12 @@ public class DbUtil {
* 処理 :引数のDBステートメントがnullでない場合、そのDBステートメントをクローズする
*/
public static void closestatement(PreparedStatement stmt) throws SQLException {
if (!stmt.equals(null)) {
//DBステートメントを閉じる
stmt.close();
}
}
/*
* TODO 以下の仕様でメソッドを作成してください。
@@ -63,6 +76,9 @@ public class DbUtil {
* 例外 :SQLException
* 処理 :引数のコネクションがnullでない場合、そのコネクションを切断する
*/
public static void closeConnection(Connection con) throws SQLException {
if (!con.equals(null)) {
con.close();
}
}
}