Static class SQL is not initialized inside IPlatformListener [message #1797127] |
Thu, 25 October 2018 20:04  |
Eclipse User |
|
|
|
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 #1797130 is a reply to message #1797128] |
Thu, 25 October 2018 21:26   |
Eclipse User |
|
|
|
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 #1805854 is a reply to message #1804989] |
Thu, 25 April 2019 14:32  |
Eclipse User |
|
|
|
marco giudici wrote on Thu, 04 April 2019 10:30Hi 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?
|
|
|
Powered by
FUDForum. Page generated in 0.04580 seconds