DbUtil

Framework Components [com.onepg.db]

← Back to Class List

Class Information

Package: com.onepg.db

Class Name: DbUtil

Description

Database utility class.

Method List

getConn

public Connection getConn()
Retrieves the default database connection.
  • Declare in a try clause (try-with-resources statement).

Return Value

Connection - the database connection

getConn

public Connection getConn(String traceCode)
Retrieves the default database connection.
  • Declare in a try clause (try-with-resources statement).

Parameters

Name Type Description
traceCode String trace code

Return Value

Connection - the database connection

getConnByConfigName

public Connection getConnByConfigName(String connName)
Retrieves a database connection with the specified connection name.
  • Declare in a try clause (try-with-resources statement).

Parameters

Name Type Description
connName String database connection name in the configuration file (the part before .dbcon.url)

Return Value

Connection - the database connection

getConnByConfigName

public Connection getConnByConfigName(String connName, String traceCode)
Retrieves a database connection with the specified connection name.
  • Declare in a try clause (try-with-resources statement).

Parameters

Name Type Description
connName String database connection name in the configuration file (the part before .dbcon.url)
traceCode String trace code

Return Value

Connection - the database connection

getConnPooled

public Connection getConnPooled()
Retrieves the default pooled database connection.
  • Retrieves a pooled database connection.
  • Declare in a try clause (try-with-resources statement).

Return Value

Connection - the database connection

getConnPooled

public Connection getConnPooled(String traceCode)
Retrieves the default pooled database connection.
  • Retrieves a pooled database connection.
  • Declare in a try clause (try-with-resources statement).

Parameters

Name Type Description
traceCode String trace code

Return Value

Connection - the database connection

getConnPooledByConfigName

public Connection getConnPooledByConfigName(String connName)
Retrieves a pooled database connection with the specified connection name.
  • Retrieves a pooled database connection.
  • Declare in a try clause (try-with-resources statement).

Parameters

Name Type Description
connName String database connection name in the configuration file (the part before .dbcon.url)

Return Value

Connection - the database connection

getConnPooledByConfigName

public Connection getConnPooledByConfigName(String connName, String traceCode)
Retrieves a pooled database connection with the specified connection name.
  • Retrieves a pooled database connection.
  • Declare in a try clause (try-with-resources statement).

Parameters

Name Type Description
connName String database connection name in the configuration file (the part before .dbcon.url)
traceCode String trace code

Return Value

Connection - the database connection

closePooledConn

public void closePooledConn()
Closes pooled database connections.
  • Disconnects all pooled database connections.
  • Also disconnects busy connections.

getConnNames

public List<String> getConnNames()
Retrieves database connection configuration names.

Return Value

List<String> - the list of connection names with URLs configured (includes the default connection name)