Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cb48440b0 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/.metadata/
|
||||||
11
.project
Normal file
11
.project
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>em-jdbc</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
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
|
||||||
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
|
||||||
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
|
||||||
@@ -44,18 +44,10 @@ public class DbUtil {
|
|||||||
* 生成されたConnectionを返却する
|
* 生成されたConnectionを返却する
|
||||||
* ※Connection生成には上記の定数を活用してください
|
* ※Connection生成には上記の定数を活用してください
|
||||||
*/
|
*/
|
||||||
public static Connection getConnection() throws ClassNotFoundException, SQLException {
|
public static Connection getConnection() throws SQLException {
|
||||||
try {
|
//データベースへの接続
|
||||||
Class.forName(DB_DRIVER);
|
con = DriverManager.getConnection(DB_URL, DB_USER, DB_PASS);
|
||||||
return DriverManager.getConnection(DB_URL, DB_USER, DB_PASS);
|
return con;
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
System.out.println();
|
|
||||||
throw e;
|
|
||||||
} catch (SQLException e) {
|
|
||||||
System.out.println();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -67,13 +59,10 @@ public class DbUtil {
|
|||||||
* 例外 :SQLException
|
* 例外 :SQLException
|
||||||
* 処理 :引数のDBステートメントがnullでない場合、そのDBステートメントをクローズする
|
* 処理 :引数のDBステートメントがnullでない場合、そのDBステートメントをクローズする
|
||||||
*/
|
*/
|
||||||
public static void closeStatement(PreparedStatement stmt) {
|
public static void closeStatement(PreparedStatement stmt) throws SQLException {
|
||||||
|
//nullチェック
|
||||||
if (stmt != null) {
|
if (stmt != null) {
|
||||||
try {
|
stmt.close();
|
||||||
stmt.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,16 +75,11 @@ public class DbUtil {
|
|||||||
* 例外 :SQLException
|
* 例外 :SQLException
|
||||||
* 処理 :引数のコネクションがnullでない場合、そのコネクションを切断する
|
* 処理 :引数のコネクションがnullでない場合、そのコネクションを切断する
|
||||||
*/
|
*/
|
||||||
public static void closeConnection(Connection con) {
|
public static void closeConnection(Connection con) throws SQLException {
|
||||||
|
//nullチェック
|
||||||
if (con != null) {
|
if (con != null) {
|
||||||
try {
|
con.close();
|
||||||
if (!con.isClosed()) {
|
|
||||||
con.close();
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user