Access login database from gameserver
Posted: Mon Mar 25, 2019 4:30 pm
Hello, I am setting up a network of 3 l2j servers, and what I am trying to do is access the login database, and read some data from the "accounts" table. However I am having trouble to do it properly. This is what I tried:
in com.l2jserver.commons.database.pool.IConnectionFactory.java:
I replaced it with this:
then I use getConnection(true) when I want to connect to the login database. I get no errors, however it still connects the gameserver database (and says there is no 'accounts' table). I think I am trying this the wrong way. Can someone help me with this?
in com.l2jserver.commons.database.pool.IConnectionFactory.java:
Code: Select all
default Connection getConnection()
{
Connection con = null;
while (con == null)
{
try
{
con = getDataSource().getConnection();
}
catch (SQLException e)
{
LOG.warn("{}: Unable to get a connection!", getClass().getSimpleName(), e);
}
}
return con;
}
Code: Select all
default Connection getConnection(boolean login)
{
Connection con = null;
while (con == null)
{
try
{
if (login)
{
System.out.println("Switching Databases.");
HikariDataSource ds = (HikariDataSource) getDataSource();
ds.setJdbcUrl("jdbc:mysql://localhost/l2jlogin?useSSL=false&serverTimezone=UTC");
con = ds.getConnection();
}
else
{
con = getDataSource().getConnection();
}
}
catch (SQLException e)
{
LOG.warn("{}: Unable to get a connection!", getClass().getSimpleName(), e);
}
}
return con;
}
default Connection getConnection()
{
return getConnection(false);
}