Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4단계 - JDBC 라이브러리 구현하기] 종이(최우종) 미션 제출합니다. #917

Open
wants to merge 1 commit into
base: dwax1324
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/src/main/java/com/techcourse/domain/UserHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
public class UserHistory {

private Long id;

private final long userId;
private final String account;
private final String password;
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/java/com/techcourse/service/TxManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.techcourse.service;

import com.interface21.jdbc.datasource.DataSourceUtils;
import com.interface21.transaction.support.TransactionSynchronizationManager;
import com.techcourse.config.DataSourceConfig;
import java.sql.Connection;
import java.sql.SQLException;
Expand All @@ -12,12 +14,16 @@ public class TxManager {
private TxManager() {
}

public static <T> T run(Function<Connection, T> function) {
public static <T> T run(Function<Connection, T> function) throws SQLException {
DataSource dataSource = DataSourceConfig.getInstance();
try (Connection connection = dataSource.getConnection()) {
Connection connection = dataSource.getConnection();
try {
return doRun(function, connection);
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
DataSourceUtils.releaseConnection(connection, dataSource);
Connection connection1 = TransactionSynchronizationManager.unbindResource(dataSource);
}
}

Expand Down