jcliff icon indicating copy to clipboard operation
jcliff copied to clipboard

JDBC driver properties can't be modified

Open fuero opened this issue 9 years ago • 3 comments

Hi,

I'm trying to get rid of these messages:

No rules for diffs:modify:/jdbc-driver/oracle-driver/driver-module-name value="com.oracle.ojdbc6"(/jdbc-driver/oracle-driver/driver-module-name value="com.oracle.ojdbc6:main")
modify:/jdbc-driver/oracle-driver/driver-datasource-class-name value="oracle.jdbc.OracleDatasource"(/jdbc-driver/oracle-driver/driver-datasource-class-name value=undefined)
modify:/jdbc-driver/oracle-driver/xa-datasource-class value="oracle.jdbc.xa.client.OracleXADataSource"(/jdbc-driver/oracle-driver/xa-datasource-class value=undefined)
modify:/jdbc-driver/oracle-driver/module-slot value="main"(/jdbc-driver/oracle-driver/module-slot value=undefined)

The file creating the datasource looks like this:

{ 
  "jdbc-driver" => { 
    "oracle-driver" => 
    {
        "driver-name" => "oracle-driver",
        "driver-module-name" => "com.oracle.ojdbc6",
        "driver-datasource-class-name" => "oracle.jdbc.OracleDatasource",
        "driver-xa-datasource-class-name" => "oracle.jdbc.xa.client.OracleXADataSource",
        "xa-datasource-class" => "oracle.jdbc.xa.client.OracleXADataSource",
        "driver-class-name" => "oracle.jdbc.driver.OracleDriver",
        "module-slot" => "main",
    }
  }
}

I've tried adding a rule to jdbc-driver allowing the attributes to be modified, but it doesn't behave as expected, because the attributes are readonly.

Furthermore it seems that driver-module-name needs to be used differently than when creating the driver (com.oracle.ojdbc6 vs. com.oracle.ojdbc6:main), so treating it like system-properties would just cause endless restarts again, right?

fuero avatar Jun 07 '15 14:06 fuero

Trying to configure jdbc drivers caused a lot of problems before. All of the properties are read-only, so the only way to change anything is to first remove the driver (which also used to be broken, I don't know if they fixed that), and then reinsert it.

Trying to change the properties will cause endless refreshes. The modify rule runs, attempting to modify a property, but it is not modified, so when the configuration is re-read, the property still has the old value, which triggers the same rule again. A while ago I added some logic to detect repetitive failures, I don't know if that logic detects this particular case.

In short, if you need to change anything with jdbc drivers, remove them first. Let me know if you have a better solution.

Thanks.

On Sun, Jun 7, 2015 at 8:15 AM, fuero [email protected] wrote:

Hi,

I'm trying to get rid of these messages:

No rules for diffs:modify:/jdbc-driver/oracle-driver/driver-module-name value="com.oracle.ojdbc6"(/jdbc-driver/oracle-driver/driver-module-name value="com.oracle.ojdbc6:main") modify:/jdbc-driver/oracle-driver/driver-datasource-class-name value="oracle.jdbc.OracleDatasource"(/jdbc-driver/oracle-driver/driver-datasource-class-name value=undefined) modify:/jdbc-driver/oracle-driver/xa-datasource-class value="oracle.jdbc.xa.client.OracleXADataSource"(/jdbc-driver/oracle-driver/xa-datasource-class value=undefined) modify:/jdbc-driver/oracle-driver/module-slot value="main"(/jdbc-driver/oracle-driver/module-slot value=undefined)

The file creating the datasource looks like this:

{ "jdbc-driver" => { "oracle-driver" => { "driver-name" => "oracle-driver", "driver-module-name" => "com.oracle.ojdbc6", "driver-datasource-class-name" => "oracle.jdbc.OracleDatasource", "driver-xa-datasource-class-name" => "oracle.jdbc.xa.client.OracleXADataSource", "xa-datasource-class" => "oracle.jdbc.xa.client.OracleXADataSource", "driver-class-name" => "oracle.jdbc.driver.OracleDriver", "module-slot" => "main", } } }

I've tried adding a rule to jdbc-driver allowing the attributes to be modified, but it doesn't behave as expected, because the attributes are readonly.

Furthermore it seems that driver-module-name needs to be used differently than when creating the driver (com.oracle.ojdbc6 vs. com.oracle.ojdbc6:main), so treating it like system-properties would just cause endless restarts again, right?

— Reply to this email directly or view it on GitHub https://github.com/bserdar/jcliff/issues/48.

bserdar avatar Jun 08 '15 04:06 bserdar

I got the idea about removing and re-adding the drivers (hence the comparison to system-properties), but in this case this approach wouldn't work if I'm not mistaken. The attributes in the resulting tree do not match the attributes supplied to the jdbc-driver:add() statement, so the computed differences would cause it to remove/re-add this over and over again.

I think it's not that big of a deal with most properties of jdbc-driver, save for module-slot.

fuero avatar Jun 08 '15 06:06 fuero

The delta is computed using the input configuration file and the current configuration tree. So, you could build the string passed to :add using those properties, and as long as the resulting configuration matches the input file, it should work. I can try this later when I have time, or if you do, please let me know.

We might need to :reload after removing jdbc driver. It complains that removed elements are still there until you :reload.

On Mon, Jun 8, 2015 at 12:15 AM, fuero [email protected] wrote:

I got the idea about removing and re-adding the drivers (hence the comparison to system-properties), but in this case this approach wouldn't work if I'm not mistaken. The attributes in the resulting tree do not match the attributes supplied to the jdbc-driver:add() statement, so the computed differences would cause it to remove/re-add this over and over again.

I think it's not that big of a deal with most properties of jdbc-driver, save for module-slot.

— Reply to this email directly or view it on GitHub https://github.com/bserdar/jcliff/issues/48#issuecomment-109876061.

bserdar avatar Jun 08 '15 13:06 bserdar