Spring JPA에서 데이터베이스 연결 풀의 기본 값

Spring JPA에서 데이터베이스 연결 풀의 기본 값 은 HikariCP 가 기본 연결 풀로 설정되어 있으며, HikariCP의 기본 설정이 적용됩니다. Spring Boot는 2.0 버전 이후부터 HikariCP를 기본 연결 풀로 사용합니다. HikariCP의 기본 설정 값 HikariCP의 주요 설정과 기본값은 다음과 같습니다: 설정 키 기본값 설명 maximumPoolSize 10 최대 연결 수. HikariCP가 유지할 수 있는 최대 커넥션 수. minimumIdle same as maximumPoolSize 풀에서 유지할 최소 유휴 연결 수. 기본적으로 maximumPoolSize 와 동일합니다. idleTimeout 600000ms (10분) 유휴 연결을 유지하는 시간. 초과하면 연결이 종료됩니다. 0으로 설정하면 비활성화됩니다. connectionTimeout 30000ms (30초) 풀에서 연결을 가져오는데 대기할 최대 시간. 이 시간 안에 연결을 가져오지 못하면 예외 발생. maxLifetime 1800000ms (30분) 연결이 풀에서 제거되기 전 최대 수명. 데이터베이스 세션 시간 초과 값보다 작게 설정 권장. validationTimeout 5000ms (5초) 연결 유효성 검사에 사용할 최대 시간. autoCommit true 연결이 풀에서 반환될 때 자동 커밋 여부. Spring Boot의 기본 연결 풀 설정 확인 Spring Boot의 기본 설정은 HikariCP의 기본값 과 동일하며, application.properties 또는 application.yml 에서 설정하지 않으면 위 값이 적용됩니다. 확인 방법 Spring Boot 애플리케이션에서 기본 설정을 확인하려면 다음과 같은 방식으로 로깅을 활성화하거나, 설정 값을 직접 확인할 수 있습니다: 로깅을 통해 확인 application.properties 에 다음 로깅 설정을 ...

Using venv in Python

Using venv in Python allows you to create a virtual environment, which is an isolated environment to manage dependencies for a specific project. Here's how you can use it step by step: 1. Create a Virtual Environment Open your terminal or command prompt. Navigate to the folder where you want to create the virtual environment. Run the following command: python -m venv myenv Replace myenv with the name you want for your virtual environment. This will create a directory named myenv containing the virtual environment. 2. Activate the Virtual Environment Activation depends on your operating system: On Windows : myenv \S cripts \a ctivate On macOS/Linux : source myenv /bin/ activate After activation, your terminal prompt will change, showing the name of the virtual environment (e.g., (myenv) ). 3. Install Dependencies With the virtual environment activated, you can now install packages using pip : pip install package _n ame For example: pip install req...

'Series' object has no attribute 'reshape'

The error 'Series' object has no attribute 'reshape' occurs because pandas.Series objects do not have a reshape method, as reshape is a method of NumPy arrays. If you're trying to reshape data, you need to convert the Series to a NumPy array first. Here's how to address this issue: Solution: Use to_numpy() to Convert to a NumPy Array Convert the Series to a NumPy array, then reshape it. import pandas as pd # Example Series s = pd.Series([ 1 , 2 , 3 , 4 , 5 , 6 ]) # Convert to NumPy array and reshape reshaped_array = s.to_numpy().reshape( 2 , 3 ) print(reshaped_array) Explanation to_numpy() : Converts the Series into a NumPy array. reshape() : Applies to NumPy arrays and allows you to specify the new dimensions. Common Use Case Example You might encounter this issue when working with data transformations, like reshaping for machine learning models: # Example: Converting a Series into a 2D array s = pd.Series([1, 2, 3, 4, 5, 6]) # Reshape t...

To get a row from a pandas.core.frame.DataFrame in Python

To get a row from a pandas.core.frame.DataFrame in Python, you can use several methods depending on how you want to access the row. Here's how you can do it: 1. Access by Index Use iloc or loc : iloc : Access by integer-based position (row number). loc : Access by label-based index. import pandas as pd # Sample DataFrame data = {' A ': [1, 2, 3], ' B ': [4, 5, 6], ' C ': [7, 8, 9]} df = pd. DataFrame ( data ) # Access the first row (integer index) row1 = df.iloc[ 0 ] print (row1) # Access a row by index label (if set) row_by_label = df.loc[ 0 ] # Assuming index is not customized print (row_by_label) 2. Access Rows Based on Conditions You can filter rows based on a condition: # Get rows where column 'A' equals 2 filtered_row = df[df[ 'A' ] == 2] print (filtered_row) 3. Access Rows Using Slicing For multiple rows, use slicing with iloc or loc : # Get the first two rows rows = df.iloc[: 2 ] print ( rows ) # Ge...

ObjectMapper In the Jackson library

In the Jackson library, you can use ObjectMapper to deserialize a JSON string into a Java object. The ObjectMapper.readValue method is commonly used for this purpose. Here's how you can do it: Example JSON String: { "name" : "Alice" , "age" : 25 } Java Class: public class Person { private String name; private int age; // Getters and setters public String getName () { return name; } public void setName (String name) { this .name = name; } public int getAge () { return age; } public void setAge ( int age) { this .age = age; } @Override public String toString () { return "Person{name='" + name + "', age=" + age + '}' ; } } Code to Deserialize: import com.fasterxml.jackson.databind.ObjectMapper; public class JsonToObjectExample { public static void main( String [] args) ...

Jackson library

In the Jackson library, the JsonNode class represents a node in a JSON tree. To extract a list (e.g., an array) from a JsonNode , you can use methods like get , elements() , or findValues . Here's how you can achieve this: Example: Extracting a List from JsonNode Given JSON: { "names" : [ "Alice" , "Bob" , "Charlie" ] } Java Code: import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class JsonNodeExample { public static void main(String[] args) throws Exception { String jsonString = "{ \"names\": [\"Alice\", \"Bob\", \"Charlie\"] }" ; // Parse JSON ObjectMapper mapper = new ObjectMapper(); JsonNode rootNode = mapper.readTree(jsonString); // Extract the "names" array as a JsonNode ...

Creating an synchronous HTTP request using Spring RestTemplate

While RestTemplate is now in maintenance mode and WebClient is recommended for new applications, it’s still widely used in existing projects. Here’s how you can configure and use RestTemplate in a Spring Boot application: 1. Add Dependencies Ensure the following dependency is present in your pom.xml : < dependency > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-starter-web </ artifactId > </ dependency > 2. Configure a RestTemplate Bean Define a RestTemplate bean in a configuration class to enable dependency injection: import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context. annotation .Bean; import org.springframework.context. annotation .Configuration; import org.springframework.web.client.RestTemplate; @Configuration public class RestTemplateConfig { @Bean public RestTemplate restTemplate(RestTemplateBuilder builder) { ret...