월 15,400원
5개월 할부 시다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
강의에서, con 객체가 언제 null이 될 수 있는지 문의드립니다.
=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용](질문 요약)질문을 요약하자면, dataSource.getConnection()이 언제 null값을 반환하는지 문의드립니다. (질문을 하게 된 배경)질문을 나름대로 해결하기 위해, 아래 사진에서(=강의 코드 캡쳐), 파란색 부분, 녹색 부분을 살펴보았습니다.여기서, 파란색 박스가 필요한 이유를 알아보고자 아래의 과정을 실험해보았습니다.=> con 객체에 강제로 null을 할당=> 녹색 박스를 거쳐서 파란색 박스로 도착하는 과정을 발견 이제, 맨 첫 번째 녹색박스에서, con객체에 언제 null이 할당되는지 파악해보려고 했는데요=> 그런데 dataSource.getConnection() 은 아래 2가지 경우만 있는 것으로 생각됩니다. (제가 실험했을 때는! 혹시 이 부분 틀렸으면 지적 부탁드립니다!!)연결 정보 등을 아예 잘못 입력하여, 연결이 안 되어서 예외를 발생Connection이 정상적으로 되어서, Connection 객체가 반환 null이 발생되는 경우는, con 객체에 강제로 null을 할당하는 것 말고는 딱히 떠오르지가 않아서..... "질문 요약" 과 같이 문의드립니다!
- 해결됨스프링 DB 1편 - 데이터 접근 핵심 원리
커넥션이 왜 10개가 만들어지는 것인가요?
영상에서 커넥션이 10개 만들어지는 것을 보여주셨는데 반복해서 코드를 실행하지 않았는데 왜 10개가 만들어지는 건가요?datasource.setMeximumPoolSize(10);은 커넥션에 풀의 최대 크기를 10개로 지정하는 것 아닌가요? 이 코드만으로 최대 크기도 지정하면서 커넥션 10개 생성까지 할 수 있는 건가요?실무에서도 보통 10개를 쓰신다고 말씀하셨는데 메이저 웹이나 어플일 경우 사용자 수가 기본 만 단위는 넘어갈텐데 10개로 다 커버가 가능한가요?
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
JDBC 반복 문제 해결 - JdbcTemplate에서 이거도 결국 AOP기술인가요?
마지막에 리포지토리까지 깔끔하게 만들었는데 이거도 서비스 로직에서 AOP사용하는 거처럼 같은 원리인거도 같은데 MemberServiceV4Test에서 @Test void AopCheck() { log.info("memberService clas={}", memberService.getClass()); log.info("memberRepository clas={}", memberRepository.getClass()); Assertions.assertThat(AopUtils.isAopProxy(memberService)).isTrue(); Assertions.assertThat(AopUtils.isAopProxy(memberRepository)).isFalse(); }얘는 잘 작동하더라구요Assertions.assertThat(AopUtils.isAopProxy(memberRepository)).isFalse(); 로요JdbcTemplate는 프록시객체 만들어서 넣어주는 방식이 아닌가여? 사실 앞으로 고급편까지 듣긴할건데 그때 나오겠죠?..
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
transactionManager.commit() 호출 시 커넥션 정리
transactionManager.commt() 또는 transactionManager.rollback()이 호출되면 트랜잭션 매니저가 자동으로 커넥션을 커넥션 풀에 반납해주는 것이 맞나요? 이때, con.setAutoCommit(true); 코드도 자동으로 실행되나요?
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
HikariProxyConnection 에 wrapping되는 커넥션
커넥션 풀에서 커넥션을 조회할 때 HikariProxyConnection 객체로 커넥션을 wrapping해서 조회한다는 것은 알겠습니다.여기에서 wrapping되는 커넥션은 (H2 DB를 사용하는 경우) JdbcConnection 객체, (MySQL DB를 사용하는 경우) MySqlConnection 객체를 의미하는 것이 맞을까요?그니까 JDBC 드라이버가 DB와 커넥션을 맺은 후 반환하는 Connection 객체를 의미하는 것이 맞을까요?찾아보니 HikariProxyConnection이 Connection 인터페이스를 구현하고 있어 헷갈려서 질문드리게 되었습니다.
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
CGLIB이 정상작동하지 않는 것 같습니다
MemberServiceV3_4Test의 AopCheck이 잘 실행이 되지 않습니다. Transactional 애노테이션이 잘 되지 않는 거 같아요. 같은 이유로 이체 중 오류 발생 시 테스트도 원하는 결과가 나오지 않네요.. 아래는 오류 내용입니다. > Task :compileJava UP-TO-DATE > Task :processResources UP-TO-DATE > Task :classes UP-TO-DATE > Task :compileTestJava UP-TO-DATE > Task :processTestResources NO-SOURCE > Task :testClasses UP-TO-DATE > Task :test FAILED 03:18:12.756 [Test worker] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper -- Neither @ContextConfiguration nor @ContextHierarchy found for test class [MemberServiceV3_4Test]: using SpringBootContextLoader 03:18:12.759 [Test worker] DEBUG org.springframework.test.context.support.AbstractContextLoader -- Could not detect default resource locations for test class [hello.jdbc.service.MemberServiceV3_4Test]: no resource found for suffixes {-context.xml, Context.groovy}. 03:18:12.780 [Test worker] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper -- Using ContextCustomizers for test class [MemberServiceV3_4Test]: [DisableObservabilityContextCustomizer, PropertyMappingContextCustomizer, Customizer, ExcludeFilterContextCustomizer, DuplicateJsonObjectContextCustomizer, MockitoContextCustomizer, TestRestTemplateContextCustomizer] 03:18:12.833 [Test worker] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider -- Identified candidate component class: file [C:\Users\TheperZ\Desktop\Spring\Spring DB\jdbc\build\classes\java\main\hello\jdbc\JdbcApplication.class] 03:18:12.834 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper -- Found @SpringBootConfiguration hello.jdbc.JdbcApplication for test class hello.jdbc.service.MemberServiceV3_4Test 03:18:12.902 [Test worker] DEBUG org.springframework.test.context.util.TestContextSpringFactoriesUtils -- Skipping candidate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener] due to a missing dependency. Specify custom TestExecutionListener classes or make the default TestExecutionListener classes and their required dependencies available. Offending class: [jakarta/servlet/ServletContext] 03:18:12.910 [Test worker] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper -- Using TestExecutionListeners for test class [MemberServiceV3_4Test]: [DirtiesContextBeforeModesTestExecutionListener, ApplicationEventsTestExecutionListener, MockitoTestExecutionListener, DependencyInjectionTestExecutionListener, DirtiesContextTestExecutionListener, TransactionalTestExecutionListener, SqlScriptsTestExecutionListener, EventPublishingTestExecutionListener, RestDocsTestExecutionListener, MockRestServiceServerResetTestExecutionListener, MockMvcPrintOnlyOnFailureTestExecutionListener, WebDriverTestExecutionListener, MockWebServiceServerTestExecutionListener, ResetMocksTestExecutionListener] 03:18:12.911 [Test worker] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener -- Before test class: class [MemberServiceV3_4Test], class annotated with @DirtiesContext [false] with mode [null] 03:18:12.919 [Test worker] DEBUG org.springframework.test.context.support.DependencyInjectionTestExecutionListener -- Performing dependency injection for test class hello.jdbc.service.MemberServiceV3_4Test . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v3.0.6) 2023-05-05T03:18:13.104+09:00 INFO 4320 --- [ Test worker] h.jdbc.service.MemberServiceV3_4Test : Starting MemberServiceV3_4Test using Java 17 with PID 4320 (started by TheperZ in C:\Users\TheperZ\Desktop\Spring\Spring DB\jdbc) 2023-05-05T03:18:13.105+09:00 INFO 4320 --- [ Test worker] h.jdbc.service.MemberServiceV3_4Test : No active profile set, falling back to 1 default profile: "default" 2023-05-05T03:18:13.569+09:00 INFO 4320 --- [ Test worker] h.jdbc.service.MemberServiceV3_4Test : Started MemberServiceV3_4Test in 0.626 seconds (process running for 1.404) 2023-05-05T03:18:13.856+09:00 INFO 4320 --- [ Test worker] h.jdbc.service.MemberServiceV3_4Test : memberService class=class hello.jdbc.service.MemberServiceV3_3$$SpringCGLIB$$0 2023-05-05T03:18:13.858+09:00 INFO 4320 --- [ Test worker] h.jdbc.service.MemberServiceV3_4Test : memberRepository class=class hello.jdbc.repository.MemberRepositoryV3 2023-05-05T03:18:13.898+09:00 INFO 4320 --- [ Test worker] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2023-05-05T03:18:13.950+09:00 INFO 4320 --- [ Test worker] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection conn0: url=jdbc:h2:tcp://localhost/~/test user=SA 2023-05-05T03:18:13.952+09:00 INFO 4320 --- [ Test worker] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2023-05-05T03:18:13.953+09:00 INFO 4320 --- [ Test worker] h.jdbc.repository.MemberRepositoryV3 : get connection=HikariProxyConnection@424743902 wrapping conn0: url=jdbc:h2:tcp://localhost/~/test user=SA, class=class com.zaxxer.hikari.pool.HikariProxyConnection 2023-05-05T03:18:13.957+09:00 INFO 4320 --- [ Test worker] hello.jdbc.connection.DBConnectionUtil : getConnection=conn1: url=jdbc:h2:tcp://localhost/~/test user=SA, class=class org.h2.jdbc.JdbcConnection 2023-05-05T03:18:13.963+09:00 INFO 4320 --- [ Test worker] h.jdbc.repository.MemberRepositoryV3 : get connection=HikariProxyConnection@1728266914 wrapping conn2: url=jdbc:h2:tcp://localhost/~/test user=SA, class=class com.zaxxer.hikari.pool.HikariProxyConnection 2023-05-05T03:18:13.964+09:00 INFO 4320 --- [ Test worker] hello.jdbc.connection.DBConnectionUtil : getConnection=conn3: url=jdbc:h2:tcp://localhost/~/test user=SA, class=class org.h2.jdbc.JdbcConnection 2023-05-05T03:18:13.984+09:00 INFO 4320 --- [ Test worker] h.jdbc.repository.MemberRepositoryV3 : get connection=HikariProxyConnection@2000856156 wrapping conn4: url=jdbc:h2:tcp://localhost/~/test user=SA, class=class com.zaxxer.hikari.pool.HikariProxyConnection 2023-05-05T03:18:13.985+09:00 INFO 4320 --- [ Test worker] hello.jdbc.connection.DBConnectionUtil : getConnection=conn5: url=jdbc:h2:tcp://localhost/~/test user=SA, class=class org.h2.jdbc.JdbcConnection Expecting value to be true but was false org.opentest4j.AssertionFailedError: Expecting value to be true but was false at java.base@17/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base@17/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base@17/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base@17/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at app//hello.jdbc.service.MemberServiceV3_4Test.AopCheck(MemberServiceV3_4Test.java:75) at java.base@17/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base@17/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base@17/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base@17/java.lang.reflect.Method.invoke(Method.java:568) at app//org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727) at app//org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at app//org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) at app//org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156) at app//org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147) at app//org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86) at app//org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103) at app//org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93) at app//org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at app//org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) at app//org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) at app//org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at app//org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92) at app//org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86) at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:217) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:213) at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:138) at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base@17/java.util.ArrayList.forEach(ArrayList.java:1511) at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base@17/java.util.ArrayList.forEach(ArrayList.java:1511) at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) at app//org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at app//org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:62) at java.base@17/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base@17/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base@17/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base@17/java.lang.reflect.Method.invoke(Method.java:568) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at jdk.proxy1/jdk.proxy1.$Proxy2.stop(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193) at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65) at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) MemberServiceV3_4Test > AopCheck() FAILED org.opentest4j.AssertionFailedError at MemberServiceV3_4Test.java:75 2023-05-05T03:18:14.004+09:00 INFO 4320 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2023-05-05T03:18:14.015+09:00 INFO 4320 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. 1 test completed, 1 failed FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':test'. > There were failing tests. See the report at: file:///C:/Users/TheperZ/Desktop/Spring/Spring%20DB/jdbc/build/reports/tests/test/index.html * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 2s 4 actionable tasks: 1 executed, 3 up-to-date
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
커넥션 관련 질문 드립니다
커넥션 풀을 이용하여 커넥션을 사용해서 반납하고 다음 커넥션을 가져올 때 conn0이라고 같은 커넥션만 가져오는 것을 볼 수 있는데 커넥션풀이 어떤 커넥션을 주는지 알고리즘이 따로 있는 걸까요? 어떤 기준으로 커넥션을 주는지 궁금합니다
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
체크예외와 런타임예외의 차이점
수업과 직접적으로 관련있다고 보긴 어려운 질문이지만, 체크예외와 런타임예외에 대해서 궁금증이 생겨서 질문 남깁니다!아래 코드는 잘 실행됩니다. 그리고 IllegalStateException 오류가 잡히고 로그가 남습니다. @Test void b(){ try { ex2(); }catch (IllegalStateException e) { log.error("message",e); } } private void ex2() throws RuntimeException{ RuntimeException ex = new IllegalStateException(); throw ex; } 그러나 아래 코드는 오류를 제공합니다.@Test void a(){ try { ex1(); }catch (SQLNonTransientException e) { log.error("message",e); } } private void ex1() throws SQLException{ SQLException ex = new SQLNonTransientException(); throw ex; } ex1()에서 java.sql.SQLException 오류가 발생합니다.첫 번째 코드가 성공하고 IllegalStateException 오류가 잡히고 로그가 남으므로 두 번째 코드도 성공해야 한다고 생각합니다.SQLNonTransientException은 SQLException의 하위 예외이므로 IllegalStateException은 RuntimeException의 하위 클래스이기 때문입니다.런타임 에러일 때 에러가 발생하면 지정된 하위 에러로 잡을 수 있는데 Check예외인 SQLException의 경우에는 적용되지 않는 이유를 알고 싶습니다.
- 해결됨스프링 DB 1편 - 데이터 접근 핵심 원리
h2 동작방식을 제가 이해하고있는지 확인해주세요
h2 애플리케이션은 jdbc:h2:tcp://localhost/~/test 즉, tcp통신을 통해 test.mv.db 파일에 데이터를 저장한다. h2.sh 애플리케이션을 실행하면 os에 org.h2.driver가 등록된다. jdbc가 제공하는 DriverManager는 os에 등록된 org.h2.driver를 관리하는 객체이다. 제가 이해한 내용이 맞을까요? 확인해주시면 감사합니다!
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
jpa와 jdbc를 같은 트랙젝션 안에서 처리하는 방법문의
public class JpaServicde { ........... @Transactional public void jpaMethod() { ExEntity exEntity = jpaRepository.save(); if (exEntity .getNo() == 1) { jdbcService.jdbcMethod(); } ................ }}public class JdbcServicde { ........... public void jdbcMethod() { ExEntity2 exEntity2 = jdbcRepository.save(); }}위와같이 JPATransaction 안에서 JDBC서비스의 메소드를 호출했는데, jdbcMethod에서 트랜젝션이 적용되지 않습니다.무엇이 잘못된 건가요?* 최대한 이해하기 쉽게 예제를 짜려고 필요한 부분만 코딩했습니다.
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
질문입니다!
https://drive.google.com/file/d/1txo4odVUdZBk8BnrLM0yAo5LKhBSpdR5/view?usp=sharing MemberServiceV4Test 가 실패했다고 나오는데 MemberRepositoryV4_2로 주입해주면 잘 되는 걸로 봐서 MemberRepositoryV5가 문제가 있는 것 같은데 아무리 찾아도 모르겠습니다 ㅠㅠ
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
Service는 특정 기술에 의존하면 안된다고 하셨는데
Spring 기술은 예외인가요 ??
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
MemberServiceV1 @RequiredArgsConstructor 질문입니다
@RequiredArgsConstructor이 애노테이션은 final이 붙은 변수의 생성자를 자동으로 생성해주고, 생성자가 하나만 있다면 @AutoWired를 생략할 수 있다고 알고 있습니다.private final MemberRepositoryV1 memberRepository;근데 여기서, MemberRepositoryV1가 Bean으로 등록되지 않았는데 어떻게 자동으로 주입을 받을 수 있는 것이죠?
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
Connection, pstmt 질문입니다
public void aaa() throws SQLException { String sql = "delete from member where member_id =?"; String memberId = "!"; try { Connection con = getConnection(); PreparedStatement pstmt = null; pstmt = con.prepareStatement(sql); } catch (Exception e) { } }이렇게 try 문 안에서 한번에 받지 않고Connection con = null; PreparedStatement pstmt = null;이렇게 null로 외부에서 선언을 하는 것은 finally 문 안에 close 메서드에 파라미터로 넘겨주기 위함이 맞나요 ?
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
DataAccessException 타입으로 던졌는데, BadSqlGrammarException으로 잡을 수 있는 이유가 궁금합니다.
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]Java 기본 문법을 여쭤보는 것 같지만 궁금합니다ㅜㅜ. 어떻게 부모타입(DataAccessException)으로 throw했는데 자식타입(BadSqlGrammarException)으로 catch할 수 있는 건가요?이렇게 테스트를 해보았는데, 잡히더라구요. 그래서 catch문에서 자동으로 upcasting이 되는건가 싶어서 RuntimeException이 아닌 Checked Exception으로도 진행을 해보았습니다.하지만 컴파일 에러가 발생하더라구요ㅜㅜ. RuntimeException만 upcasting을 해주는 건지, 아니라면 어떻게 자식타입으로 catch할 수 있는건지 궁금합니다!
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
중요하지 않은 오타..
4. 스프링과 문제 해결 - 트랜잭션.pdfJpaTransactionManage -> JpaTransactionManagerHibernate, Etc 동일하게 r이 하나 빠졌습니다. 좋은 강의 항상 감사드립니다.
- 해결됨스프링 DB 1편 - 데이터 접근 핵심 원리
트랜잭션이 적용되지 않는 메소드에 대해서 궁금합니다.
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]강의에서는 accountTransfer 메소드에 @Transactional을 붙여서 트랜잭션 관리가 되도록 했는 데 만약에 같은 클래스에서 @Transactional이 붙어 있지 않는 메소드에서는 트랜잭션 매니저를 거치는 지, 만약 거치지 않는 다면 어떻게 작동하는 지 궁금합니다.
- 해결됨스프링 DB 1편 - 데이터 접근 핵심 원리
JdbcUtils.closeConnection 질문입니다.
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]커넥션 풀 안에 있는 커넥션을 획득해서 사용한 후에, JdbcUtils.closeConnection() 메소드를 실행하면 커넥션이 끊길것 같은데, 끊기면 안되지 않나요? 왜냐하면 커넥션 풀 안에 있는 커넥션들은 계속 DB와 연결되어 있어야 한다고 생각해서요!!!
- 해결됨스프링 DB 1편 - 데이터 접근 핵심 원리
ThreadLocal을 사용하는 이유에 대한 질문
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]ThreadLocal을 사용하는 이유가 쓰레드는 기본적으로 다른 쓰레드와 리소스를 공유하게 되는데 커넥션을 반환했다가 다시 가져오는 과정에서 혹여나 다른 요청으로 인해 커넥션을 다른 요청이 가져가 버릴까봐 ThreadLocal을 사용하여 하나의 요청에서 계속 사용할 수 있게하기 위해서인가요?
- 미해결스프링 DB 1편 - 데이터 접근 핵심 원리
MemberServiceV3_2에서 PlatformTransactionManager로 주입받는 것
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]6분 40초쯤 부분에서 transactionManager를 PlatformTransactionManager 로 받으면 유연성이 더 생긴다고 설명하신 부분에 대한 질문입니다.김영한님께서 주시는 가르침들에 대해서 최대한 세세한 것 까지 흡수하고자 노력하고있습니다.저 부분에서 설명하신 이유에 대해서 조금만 더 자세히 설명해주실 수 있을까요?