Hi Pascal,

Your example is a Bootique app. So it will have its connection info in 
config.yml, and you don't need the properties. If you use your model in another 
app that is not a Bootuque app, then the -D properties will work.

Or did I misunderstand your use case?

Andrus


> On Jun 12, 2017, at 5:31 PM, Pascal Robert <[email protected]> wrote:
> 
> Tried that, no luck (at least with the Bootique app):
> 
> java 
> -Dcayenne.jdbc.url="jdbc:mysql://xx.xx.xx.xx:3306/filemaker?connectTimeout=0&autoReconnect=true"
>  -jar RevendeursWeb-1.0.jar --config=config.yml —server
> 
> Still connect to the URL defined in the model.
> 
>> Le 12 juin 2017 à 09:32, Nikita Timofeev <[email protected]> a écrit 
>> :
>> 
>> Hi Pascal,
>> 
>> Yes you can setup DataSource via PropertyDataSourceFactory[1] that can
>> read all information from runtime properties.
>> All you need is to provide those properties via env variables or
>> directly in your code like this (this code for the latest 4.0
>> version):
>> 
>> ServerRuntime cayenneRuntime = ServerRuntime.builder()
>>       .addConfig("cayenne-project.xml")
>>       .addModule(binder -> {
>>           ServerModule.contributeProperties(binder)
>>                   .put("cayenne.jdbc.driver", "com.mysql.Driver")
>>                   .put("cayenne.jdbc.url", "jdbc:mysql://127.0.0.1:3306/");
>>       })
>>       .build();
>> 
>> [1] 
>> http://cayenne.apache.org/docs/4.0/api/org/apache/cayenne/configuration/server/PropertyDataSourceFactory.html
>> 
>> On Mon, Jun 12, 2017 at 3:59 PM, Pascal Robert <[email protected]> wrote:
>>> 
>>>> Le 9 juin 2017 à 11:37, Andrus Adamchik <[email protected]> a écrit :
>>>> 
>>>> The easiest thing is to remove the DataNode from CayenneModel completely, 
>>>> and use Bootique connections locally, in production and in other 
>>>> environments.
>>> 
>>> And can I set the connection information in another way for non-Bootique 
>>> apps?
>>> 
>>>> Andrus
>>>> 
>>>>> On Jun 9, 2017, at 6:14 PM, Pascal Robert <[email protected]> wrote:
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> I’m deploying my first Bootique app, which use Cayenne. In my config.yml 
>>>>> file, I set the datasource like this:
>>>>> 
>>>>> jdbc:
>>>>> mysql:
>>>>> driverClassName: com.mysql.jdbc.Driver
>>>>> url: 
>>>>> "jdbc:mysql://10.6.xx.xx:3306/filemaker?connectTimeout=0&autoReconnect=true"
>>>>> initialSize: 1
>>>>> username: xxxxx
>>>>> password: xxxxx
>>>>> 
>>>>> cayenne:
>>>>> datasource: mysql
>>>>> 
>>>>> But when I make a request to the app, it tries to connect to the server 
>>>>> defined in the data model, not from the configuration file.
>>>>> 
>>>>> INFO  [2017-06-09 15:08:32,255] bootique-http-36 
>>>>> o.a.c.c.XMLDataChannelDescriptorLoader: Loading XML configuration 
>>>>> resource from 
>>>>> jar:file:/opt/bin/RevendeursWeb-1.0.jar!/cayenne-filemaker.xml
>>>>> INFO  [2017-06-09 15:08:32,278] bootique-http-36 
>>>>> o.a.c.c.XMLDataChannelDescriptorLoader: Loading XML DataMap resource from 
>>>>> jar:file:/opt/bin/RevendeursWeb-1.0.jar!/mysql.map.xml
>>>>> INFO  [2017-06-09 15:08:32,332] bootique-http-36 
>>>>> o.a.c.c.XMLDataChannelDescriptorLoader: Loading XML DataMap resource from 
>>>>> jar:file:/opt/bin/RevendeursWeb-1.0.jar!/revendeurs.map.xml
>>>>> INFO  [2017-06-09 15:08:32,338] bootique-http-36 
>>>>> o.a.c.c.XMLDataChannelDescriptorLoader: Loading XML DataMap resource from 
>>>>> jar:file:/opt/bin/RevendeursWeb-1.0.jar!/utilisateurs.map.xml
>>>>> 
>>>>> INFO  [2017-06-09 15:08:32,366] bootique-http-36 
>>>>> o.a.c.d.DriverDataSource: Connecting to 
>>>>> 'jdbc:mysql://legestionnaire.druide:3306/filemaker' as 'filemaker'
>>>>> INFO  [2017-06-09 15:08:32,413] bootique-http-36 
>>>>> o.a.c.d.DriverDataSource: *** Connecting: FAILURE.
>>>>> 
>>>>> What’s the trick?
>>>> 
>>> 
>> 
>> 
>> 
>> -- 
>> Best regards,
>> Nikita Timofeev
> 

Reply via email to