Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Static class SQL is not initialized inside IPlatformListener
Static class SQL is not initialized inside IPlatformListener [message #1797127] Thu, 25 October 2018 20:04 Go to next message
Miloslav Frajdl is currently offline Miloslav FrajdlFriend
Messages: 48
Registered: June 2018
Member
Hi,
I have some problem.

I want to create a scheduled service working with SQL. I created my own IPlatformListener, but the static class "SQL" is not initialized and can not be used.

@Bean
public class ServerApplication implements IPlatformListener {
	private static final Logger LOG = LoggerFactory.getLogger(ServerApplication.class);

	@Override
	public void stateChanged(PlatformEvent event) {
		if (event.getState() == IPlatform.State.PlatformStarted) {
			String x = SQL.getDriverName();   // <<< x is null


In the above example, x is null, although the OracleSQLService class is declared and elsewhere in the project works.

public class OracleSQLService extends AbstractOracleSqlService {

	@Override
	protected String getConfiguredPassword() {
		return "<right password>";
	}

	@Override
	protected String getConfiguredUsername() {
		return "<right user>";
	}

	@Override
	protected String getConfiguredJdbcMappingName() {
		return "jdbc:oracle:thin:@localhost:1521/orcl";
	}
}


Can anyone advise me what to do with it?

Thank you for the advice.
Re: Static class SQL is not initialized inside IPlatformListener [message #1797128 is a reply to message #1797127] Thu, 25 October 2018 20:08 Go to previous messageGo to next message
Miloslav Frajdl is currently offline Miloslav FrajdlFriend
Messages: 48
Registered: June 2018
Member
Addition:

Using SQL.select(...) caused Assertion error: Transaction required
Re: Static class SQL is not initialized inside IPlatformListener [message #1797130 is a reply to message #1797128] Thu, 25 October 2018 21:26 Go to previous messageGo to next message
Matthias OtterbachFriend
Messages: 55
Registered: August 2015
Location: Munich
Member
That is because you do not have an active transaction, e.g. ITransaction.CURRENT.get() returns null/is not set.

You can probably fix it by running the SQL method calls within a (empty) RunContext which will provide a new transaction:

    @Override
    public void stateChanged(final PlatformEvent event) {
      if (event.getState() == State.PlatformStarted) {
        RunContexts.empty().run(() -> System.out.println(SQL.getDriverName()));
      }
    }
Re: Static class SQL is not initialized inside IPlatformListener [message #1797147 is a reply to message #1797130] Fri, 26 October 2018 09:59 Go to previous messageGo to next message
Miloslav Frajdl is currently offline Miloslav FrajdlFriend
Messages: 48
Registered: June 2018
Member
Thank you for response. That solved my problem.
Re: Static class SQL is not initialized inside IPlatformListener [message #1804989 is a reply to message #1797147] Thu, 04 April 2019 10:30 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi Frajdl,
which version of Scout do you use?
I use Scout 8.0 with Eclipse Photon ver 2018-09 (4.9.0) and I have difficult to enable/install/configure Oracle JDBC and work with AbstractOracleSqlService.

Could you help me on this task?

Thanks in advance for your help

Marco
Re: Static class SQL is not initialized inside IPlatformListener [message #1805854 is a reply to message #1804989] Thu, 25 April 2019 14:32 Go to previous message
Matthias OtterbachFriend
Messages: 55
Registered: August 2015
Location: Munich
Member
marco giudici wrote on Thu, 04 April 2019 10:30
Hi Frajdl,
which version of Scout do you use?
I use Scout 8.0 with Eclipse Photon ver 2018-09 (4.9.0) and I have difficult to enable/install/configure Oracle JDBC and work with AbstractOracleSqlService.


Which kind of difficulty do you have/has the problem already been resolved? Is there any error/stacktrace displayed?
Previous Topic:Lookup Call
Next Topic:Translation of texts built into the scout platform
Goto Forum:
  


Current Time: Thu Apr 18 16:03:49 GMT 2024

Powered by FUDForum. Page generated in 0.02221 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top