I am writing a web service project with Eclipse, connecting to Firebird database using Tomcat 8 server. Problem is in IBExpert tool, connections from Tomcat show null value in "Remote Process" column, so I don't know which connection comes from Tomcat.
Is there anyway to naming the connections of Tomcat in there? Maybe show path of Tomcat exe file or simply give it a text?
Here the code I use to create connection with HirakiCP library.
public class DBConnection {
private static final int READ_ONLY = 0;
private static final int READ_WRITE = 1;
private static final int CREATE_NEW = 2;
private static HikariConfig config;
private static HikariDataSource datasource;
public static DataSource getDataSource(String dbIP, String dbName,
String dbUsername, String dbPassword) {
if (datasource == null) {
config = new HikariConfig();
config.setDriverClassName(Constants.DB_DRIVER);
config.setJdbcUrl(Constants.DB_URL + dbIP + "/" + dbName
+ "?dialect=3&lc_ctype=UNICODE_FSS");
config.setUsername(dbUsername);
config.setPassword(Utility.dbDecrypt(dbPassword));
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
config.setMaximumPoolSize(5);
config.setMinimumIdle(2);
config.setConnectionTimeout(TimeUnit.SECONDS.toMillis(30));
config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(10));
datasource = new HikariDataSource(config);
}
return datasource;
}
/*
* Method to create DB connection
*
* @param dbIP
*
* @param dbName
*
* @param dbUsername
*
* @param dbPassword
*
* @return connection
*/
@SuppressWarnings("finally")
public static Connection createConnection(String dbIP, String dbName,
String dbUsername, String dbPassword, int conType) {
Connection con = null;
if (datasource == null) {
// Create new datasource
datasource = (HikariDataSource) getDataSource(dbIP, dbName,
dbUsername, dbPassword);
}
try {
// Use existing datasource
con = datasource.getConnection();
if (conType == READ_ONLY) {
con.setReadOnly(true);
} else {
con.setReadOnly(false);
}
} finally {
return con;
}
}
}
This is not specific to IB Expert (which is also why I removed that tag from your question). This is information reported by the MON$ATTACHMENTS
table of Firebird.
When using Jaybird (the Firebird JDBC driver) you have a number of options to set the process name:
org.firebirdsql.jdbc.processName
. For example, by:
-Dorg.firebirdsql.jdbc.processName=Tomcat
in the startup script of TomcatSystem.setProperty("org.firebirdsql.jdbc.processName", "Tomcat")
before initializing the connection pool.processName
. For example, by:
processName=Tomcat
in the JDBC URLconfig.addDataSourceProperty("processName", "Tomcat")
See also Process information in the Jaybird JDBC Driver Java Programmer's Manual.
Disclosure: I maintain the Jaybird driver, and wrote parts of the documentation I linked.