【问题标题】:WLST command to update JDBC DataSource URL用于更新 JDBC 数据源 URL 的 WLST 命令
【发布时间】:2013-08-07 13:57:06
【问题描述】:

我使用 Weblogic 控制台导航到数据源并更新我的数据源中的 URL。 有什么方法可以让我使用 WLST 命令做同样的事情。我需要从命令更新。

我只需要更新我的数据源的 URL。

【问题讨论】:

    标签: java jdbc weblogic datasource wlst


    【解决方案1】:

    我们通过 wlst 脚本以稍微不同的方式执行此操作:

    edit()
    
    # set url and remove the target so we can redeploy without 
    # restarting managed server
    startEdit()
    
    cd("/JDBCSystemResources/"+dsName)
    targets = get('Targets')
    
    # set an array ob empty objects to the datasource's targets
    set('Targets',jarray.array([], ObjectName))
    
    cd("JDBCResource/"+dsName+"/JDBCDriverParams/"+dsName)
    set("Url", dbURL)
    
    save()
    activate()
    
    # reset thge original targets so the datasource will be refreshed
    startEdit()
    cd("/JDBCSystemResources/"+dsName)
    set('Targets', targets)
    
    save()
    activate()
    

    我发现我需要在这里做的事情是更改数据源对象上的 URL 不会将其重新部署到数据源附加到的任何托管托管服务器。如果您使用托管服务器,则必须将目标设置为空,保存数据源,然后设置原始目标,再次保存。这会将数据源重新部署到任何托管服务器。

    唯一的其他选择是重新启动任何托管服务器。

    如果您的管理服务器也是您的托管服务器(即没有托管服务器),您无需担心上述脚本中的目标会受到任何干扰。

    【讨论】:

      【解决方案2】:

      是的,可以使用 WLST 在线命令。假设“myds”是您希望更改 URL 的示例数据源名称。您必须在编辑树中才能进行更改。 URL 在 JDBCDriverParams mbean 树中可用,因此导航到该 mbean,然后使用 setUrl 命令设置属性以将当前值更改为新值。更改后使用 save()、activate() 命令。

      `

           1. cd('/JDBCSystemResources/myds/JDBCResource/myds')
           2. cd('JDBCDriverParams/myds')
           3. ls()
           4. cmo.setUrl('new.db.url:port')
      

      ` 有关更多详细信息,您可以参考一些 WLST datasource configuration 脚本。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-03-22
        • 1970-01-01
        • 2018-03-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-09-13
        相关资源
        最近更新 更多