File tree Expand file tree Collapse file tree 3 files changed +6
-11
lines changed
java/com/example/cloudsql Expand file tree Collapse file tree 3 files changed +6
-11
lines changed Original file line number Diff line number Diff line change 37
37
</properties >
38
38
39
39
<dependencies >
40
-
41
- <!-- Required only for AppEngine Standard -->
42
- <dependency >
43
- <groupId >com.google.appengine</groupId >
44
- <artifactId >appengine-api-1.0-sdk</artifactId >
45
- <version >1.9.64</version >
46
- </dependency >
47
-
48
40
<dependency >
49
41
<groupId >javax.servlet</groupId >
50
42
<artifactId >javax.servlet-api</artifactId >
79
71
<scanIntervalSeconds >1</scanIntervalSeconds >
80
72
</configuration >
81
73
</plugin >
74
+ <!-- Only required for AppEngine Deployments -->
82
75
<plugin >
83
76
<groupId >com.google.cloud.tools</groupId >
84
77
<artifactId >appengine-maven-plugin</artifactId >
Original file line number Diff line number Diff line change 26
26
import javax .servlet .annotation .WebListener ;
27
27
import javax .sql .DataSource ;
28
28
29
- @ WebListener
29
+ @ WebListener ( "Creates a connection pool that is stored in the Servlet's context for later use." )
30
30
public class ConnectionPoolContextListener implements ServletContextListener {
31
31
32
32
private static final String CLOUD_SQL_INSTANCE_NAME = System .getenv ("CLOUD_SQL_INSTANCE_NAME" );
@@ -74,7 +74,9 @@ private DataSource mysqlConnectionPool() {
74
74
75
75
// [START cloud_sql_connection_lifetime]
76
76
// maxLifetime is the maximum possible lifetime of a connection in the pool. Connections that
77
- // live longer than this many milliseconds will be closed and reestablished between uses.
77
+ // live longer than this many milliseconds will be closed and reestablished between uses. This
78
+ // value should be several minutes shorter than the database's timeout value to avoid unexpected
79
+ // terminations.
78
80
config .setMaxLifetime (1800000 ); // 30 minutes
79
81
// [END cloud_sql_connection_lifetime]
80
82
Original file line number Diff line number Diff line change 23
23
<env-var name =" DB_PASS" value =" my-db-password" />
24
24
<env-var name =" DB_NAME" value =" my_db" />
25
25
</env-variables >
26
- </appengine-web-app >
26
+ </appengine-web-app >
You can’t perform that action at this time.
0 commit comments