forked from sunday-develop/toby-spring
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
앞서 SimpleConnectionMaker에 종속적이 었으므로 확장이 어려웠다. 중간에 추상적인 느슨한 연결고리인 인터페이스를 만들어줌으로써, 긴밀하게 연결되지 않도록 변경할 수 있다. 하지만, UserDao에서 ConnectionMaker를 생성하는 코드는 여전히 남아있다.
- Loading branch information
1 parent
7f5ae21
commit a2de774
Showing
6 changed files
with
28 additions
and
21 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/main/java/com/toby/tobyspring/user/dao/ConnectionMaker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.toby.tobyspring.user.dao; | ||
|
||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
|
||
public interface ConnectionMaker { | ||
public Connection makeNewConnection() throws ClassNotFoundException, SQLException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
src/main/java/com/toby/tobyspring/user/dao/NUserConnectionMaker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.toby.tobyspring.user.dao; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
|
||
public class NUserConnectionMaker implements ConnectionMaker { | ||
@Override | ||
public Connection makeNewConnection() throws ClassNotFoundException, SQLException { | ||
Class.forName("oracle.jdbc.driver.OracleDriver"); | ||
Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "dahye", "dahye"); | ||
return connection; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters