I tried to configure the connections created using the postgresql data source declared in the Spring xml configuration file.
<bean id="myDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql://localhost:5432/dbname" />
<property name="username" value="postgres" />
<property name="password" value="" />
<property name="socketTimeout" value="10"/>
</bean>
I know I should not use a class DriverManagerDataSourcefrom spring, (we will move on to C3p0 or DBCP soon), because this is not a real pool. I am trying to set the socketTimeout value of a postgresql connection (described here https://jdbc.postgresql.org/documentation/head/connect.html ), but of course, "socketTimeout" is not a property of the data source, so it does not work.
Can this be done through datasource xml data configuration? Or should I do it somewhere else? Since the data source controls the connection, I donβt think I can do
props.setProperty("timeout",30);
Connection conn = DriverManager.getConnection(url, props);
DriverManagerDataSource? , , .