Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Defining and using datasources in scout
Defining and using datasources in scout [message #1401894] Wed, 16 July 2014 08:09 Go to next message
Lukas Steigerwald is currently offline Lukas SteigerwaldFriend
Messages: 47
Registered: July 2014
Member
I am trying to make Scout work with data from initial context. E.g. Getting a string or a datasource. Background is that the final product would be delivered to clients that define their datasource on the application server they are running the application on (most likely that will be websphere). Scout has somehow to find the datasource and use it for the services interacting with the DB.
My problem currently is that I am a bit confused where I am setting the parameters to get from initial context in the Eclipse IDE using Scout. There is a lot of magic going on in the SDK that really confuses me (especially as I am not too familiar with datasources and context)as I am not able to discover where to define context parameters and datasources for the Scout Server (that seems to be somehow included in the SDK and not beeing a separate server I could somehow access). Maybe it is a stupid question, but I am currently stuck at this point.
I am very thankful for the nice replies I received on my othe questions during the last days and hopefully you will be able to help me with this as well.
Re: Defining and using datasources in scout [message #1402022 is a reply to message #1401894] Wed, 16 July 2014 11:46 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 973
Registered: October 2011
Senior Member
Typical (or simple) scout applications connect to a Database using a simple JDBC layer. In this case you do not rely in any datasource defined in an application server.

This is what is described in the MiniCRM tutorial > Set up SQL Service step.

There not so much magic in the SDK:
* When you create a new scout project an initial template is used.
* The wizards and the views allow you to create java code a little bit quicker than if you had to write it.

Scout RT also offers some convenience mechanisms. For example, for the Database configuration, values in config.ini can be used. (more about ServiceUtility.injectConfigProperties(..) in the forum).

Now back to your question:
I do not know how and if we can access a Datasource defined in an Application Server (isn't it a JavaEE concept?). I will try to ask someone who might know.

Re: Defining and using datasources in scout [message #1402041 is a reply to message #1401894] Wed, 16 July 2014 12:28 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 973
Registered: October 2011
Senior Member
Duplicate post.

[Updated on: Wed, 16 July 2014 12:53]

Report message to a moderator

Re: Defining and using datasources in scout [message #1402085 is a reply to message #1402041] Wed, 16 July 2014 13:47 Go to previous messageGo to next message
Lukas Steigerwald is currently offline Lukas SteigerwaldFriend
Messages: 47
Registered: July 2014
Member
Thank you for your reply Jeremie =)
The basic concept of using a Database from within the Scout IDE works perfectly fine for me already. The background of my question regarding the implementation of data sources is the reason that the apllication package should be delivered to a client and the client needs to enter his parameters for accessing an already existing database. The advantage of a datasource would be to get the datasource by openening a handle to a specific name. The server takes care of which datasource is actually behind the name and gives a handle to the application requesting the resource behind the specific name.

The concept of defining data sources in the context is supported bei JEE application servers but as well by tomcat that is used in the deployment tutorial. I would be great if you could manage to ask someone who might know about this topic =)

And what I wanted to say with magic is that it is a bit unclear to me how Scout runs in Eclipse. I was not able to figure out where the server the application is running on is located and how to configure it. As well I did not find a point to influence the resulting web.xml that is included in the exported WAR.

Re: Defining and using datasources in scout [message #1404621 is a reply to message #1402085] Mon, 04 August 2014 14:10 Go to previous messageGo to next message
Lukas Steigerwald is currently offline Lukas SteigerwaldFriend
Messages: 47
Registered: July 2014
Member
Are there any news on this topic? Is there any way to include a JNDI mapped datasource that is configured in an application server? Or any other way to configure the database after packaging the EAR? What could be helpful as well: Can I somehow influence the web.xml and application.xml that are included when exporting my application as WAR or EAR?
Re: Defining and using datasources in scout [message #1407042 is a reply to message #1404621] Mon, 11 August 2014 18:43 Go to previous messageGo to next message
Lukas Huser is currently offline Lukas HuserFriend
Messages: 42
Registered: March 2010
Member
Hi Lukas

As far as I know, Scout supports access to JNDI data sources. I think the setup should work similar to configuring a direct JDBC connection as described in the tutorials. I'm not able to try this myself at the moment but the following pointers should get you going.

Have a look at AbstractSqlService and its different configuration properties. With getConfiguredDirectJdbcConnection() returning false, you can switch to JNDI data sources (default ist true, which creates direct JDBC connections). Make sure to provide the correct connection details with getConfiguredJndiName() and the different getConfiguredJndi* methods.

Note: Instead of overriding the getConfiguredXXX methods directly in your SqlService, you should probably define the corresponding properties in the servers config.ini file. This way you can set up a JNDI connection for your productive (e.g. deployed) environment, while using a direct JDBC connection in your development environment (when starting the server from Eclipse).


Hope this helps
Lukas
Re: Defining and using datasources in scout [message #1407398 is a reply to message #1407042] Tue, 12 August 2014 13:57 Go to previous message
Lukas Steigerwald is currently offline Lukas SteigerwaldFriend
Messages: 47
Registered: July 2014
Member
Thank you Lukas =) That helped a lot.
One more thing that would be great: Is there any possible solution I could offer a client after packaging the application to an EAR to define the JNDI-name he wants to use?
Previous Topic:Saving users table customisation
Next Topic:SCout ORM
Goto Forum:
  


Current Time: Tue Jul 07 09:17:30 GMT 2015

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

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