不兼容的类型端口Bluemix JAVA SQL

时间:2015-06-22 15:05:06

标签: ibm-cloud

我一直试图在BlueMix上连接SQL一段时间。 我收到了错误:

port = ((int) obj.get("port"));

不兼容的类型。

我从提供的演示中复制了代码: https://hub.jazz.net/project/pvanrun/SQLDBJava/overview

我试图把它翻到:

port = Integer.valueOf((String) obj.get("port"));

然而,我收到此错误:

Exception thrown by application class 'com.ibm.callcenter.data.SQLDatabase.processVCAP:144'
java.lang.ClassCastException: java.lang.Integer incompatible with java.lang.String
at com.ibm.callcenter.data.SQLDatabase.processVCAP(SQLDatabase.java:144)
at com.ibm._jsp._index._jspService(_index.java:98)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:101)
at [internal classes]

1 个答案:

答案 0 :(得分:0)

似乎在developerWorks上已经问过类似的问题:

https://developer.ibm.com/answers/questions/20560/issue-connecting-to-sqldb-service-instance-from-java-struts-app.html

端口是一个整数。尝试更改

 port = (String) obj.get("port"); 

到整数

 port = (Integer) obj.get ("port");

或者在SQLDB VCAP服务中使用'jdbcurl'属性:

 connectionUrl = (String) obj.get("jdbcurl");