Access login database from gameserver

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
DjSt3rios
Posts: 30
Joined: Thu Sep 16, 2010 7:00 pm

Access login database from gameserver

Post by DjSt3rios » 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:

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;
	}
I replaced it with this:

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);
	}
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?

Post Reply