RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.game.service.PostgreService Class Reference

Static Public Member Functions

static Connection getConnection () throws SQLException
static HikariDataSource getConnectionPool ()
static void start () throws Exception

Static Private Attributes

static HikariDataSource connectionPool
static final Logger logger = LogManager.getLogger(PostgreService.class)

Detailed Description

Definition at line 14 of file PostgreService.java.

Member Function Documentation

◆ getConnection()

Connection com.runehive.game.service.PostgreService.getConnection ( ) throws SQLException
static

Definition at line 39 of file PostgreService.java.

39 {
40 if (Config.WORLD_TYPE != WorldType.LIVE) {
41 return DriverManager.getConnection(Config.POSTGRE_URL, Config.POSTGRE_USER, Config.POSTGRE_PASS);
42 }
43 return connectionPool.getConnection();
44 }

References connectionPool, com.runehive.game.world.WorldType.LIVE, com.runehive.Config.POSTGRE_PASS, com.runehive.Config.POSTGRE_URL, com.runehive.Config.POSTGRE_USER, and com.runehive.Config.WORLD_TYPE.

◆ getConnectionPool()

◆ start()

void com.runehive.game.service.PostgreService.start ( ) throws Exception
static

Definition at line 20 of file PostgreService.java.

20 {
21 HikariConfig config = new HikariConfig();
22 config.setDriverClassName("org.postgresql.Driver");
23 config.setJdbcUrl(Config.POSTGRE_URL);
24 config.setUsername(Config.POSTGRE_USER);
25 config.setPassword(Config.POSTGRE_PASS);
26 config.setMaximumPoolSize(50);
27 config.setConnectionTimeout(10_000);
28 config.setIdleTimeout(0);
29 config.setMaxLifetime(0);
30 config.addDataSourceProperty("cachePrepStmts", "true");
31 connectionPool = new HikariDataSource(config);
32 logger.info("Successfully connected to game database.");
33 }

References connectionPool, logger, com.runehive.Config.POSTGRE_PASS, com.runehive.Config.POSTGRE_URL, and com.runehive.Config.POSTGRE_USER.

Referenced by com.runehive.RuneHive.start().

Here is the caller graph for this function:

Member Data Documentation

◆ connectionPool

HikariDataSource com.runehive.game.service.PostgreService.connectionPool
staticprivate

Definition at line 18 of file PostgreService.java.

Referenced by getConnection(), getConnectionPool(), and start().

◆ logger

final Logger com.runehive.game.service.PostgreService.logger = LogManager.getLogger(PostgreService.class)
staticprivate

Definition at line 16 of file PostgreService.java.

Referenced by start().


The documentation for this class was generated from the following file: