ibmcloud部署mysql_系列4:部署刚才的hello mysql jdbc到bluemix云

引子:https://www.ng.bluemix.net/docs/#starters/liberty/index.html#libertyapp

When the application is bound to services, the service binding information is available in the VCAP_SERVICES environment variable. For some services, Liberty automatically generates or updates service binding entries in the server.xml file.

The Liberty buildpack automatically processes service bindings for the following service types:

Relational DataBase (SQLDB via DB2®)

NoSQL DataBase (Mongo)

Logging (LogAnalysis)

正文:

SO.不能自动给MYSQL注入jdbc连接信息了.!不过还是要试一下

以相同的方式打包:

C:\IBM\was855nalp\bin>server package simpleServer --archive=hellotest.zip --include=usr

Packaging server simpleServer.

Server simpleServer package complete in C:\IBM\was855nalp\usr\servers\simpleServer\hellotest.zip.

C:\IBM\was855nalp\bin>

这回打的包有1M多,它自动包含了/usr/shared目录

cf login -a https://api.ng.bluemix.net(如果刚才已经登录过,此步不是必须的)

cf bind-service cyperhellotest mysql-cyper(这次先绑定事先建好的mysql服务,可以通过cf services查看已有的服务,如果已经绑定过则可以跳过此步)

cf push cyperhellotest --no-manifest --no-start -p C:\IBM\was855nalp\usr\servers\simpleServer\hellotest.zip(再次上传bluemix足够聪明,usr/shared/resources中的mysql jar这次被无视了)

cf start cyperhellotest

cf logs cyperhellotest

访问url, 只打印出了页面上的静态内容,没有打出DB中的记录

从日志中看出,,失败了!

从bluemix portal中找到VCAP信息,修改server.xml如下

servlet-3.0

jdbc-4.0

重新打包部署.

server package simpleServer --archive=hellotest.zip --include=usr

cf push cyperhellotest --no-manifest -p C:\IBM\was855nalp\usr\servers\simpleServer\hellotest.zip

通过cyperhellotest.ng.bluemix.net/helloworld/HelloServlet

或cyperhellotest.mybluemix.net/helloworld/HelloServlet

访问成功

0ccad06159b4d6c212534f9447774bb5.png

PS:如果因为某些原因报Table cities already exists!, 则在create table前drop table就行了.

drop table if exists cities

create table if not exists cities

0624更新配置如下:

databaseName="${cloud.services.mysql-cyper.connection.name}"

serverName="${cloud.services.mysql-cyper.connection.host}"

portNumber="${cloud.services.mysql-cyper.connection.port}"

user="${cloud.services.mysql-cyper.connection.user}"

password="${cloud.services.mysql-cyper.connection.password}" />

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值