无法使用JDBC

时间:2017-07-12 02:59:53

标签: hana

我正在尝试使用JDBC连接到SAP HANA 2.0。我从我在Windows中安装的Eclipse插件中获取了驱动程序ngdbc.jar

问题是,即使我在连接字符串中设置了一个随机IP地址,我总是得到相同的错误[Connection refused: connect], -813

Eclipse插件完美连接:

enter image description here

可能是什么问题?这是ngdbc.jar跟踪:

ClassLoader: sun.misc.Launcher$AppClassLoader@73d16e93
Process-ID: 3140
package package com.sap.db.jdbc, Java Platform API Specification, version 1.6, SAP HANA JDBC Driver, SAP SE, 2.0.14-2d2417a0b831eafc24c4a6d30206b73d62a858e5 on Java 1.8.0_131


---- Thread 3e3abc88 main Timestamp: 2017-07-11 22:47:06.243
new Connection 'jdbc:sap://192.168.1.85:39015/'
user=SYSTEM
password=***
HOSTLIST: [192.168.1.85:39015,]
new RTEException: SQLSTART_REQUIRED(5) -813 Cannot connect to host 192.168.1.85:39015 [Connection refused: connect], -813.
whereAmIjava.lang.Throwable
    at com.sap.db.jdbc.trace.Tracer.whereAmI(Tracer.java:333)
    at com.sap.db.jdbc.exceptions.RTEException.<init>(RTEException.java:46)
    at com.sap.db.jdbc.exceptions.RTEException.<init>(RTEException.java:23)
    at com.sap.db.jdbc.Session._openSocket(Session.java:1005)
    at com.sap.db.jdbc.Session.openSocket(Session.java:416)
    at com.sap.db.jdbc.Session$1.open(Session.java:915)
    at com.sap.db.jdbc.Topology.getSession(Topology.java:214)
    at com.sap.db.jdbc.Driver._connect(Driver.java:814)
    at com.sap.db.jdbc.Driver.connect(Driver.java:159)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at fdic.LoadBankReferenceData$.delayedEndpoint$fdic$LoadBankReferenceData$1(LoadBankReferenceData.scala:20)
    at fdic.LoadBankReferenceData$delayedInit$body.apply(LoadBankReferenceData.scala:12)
    at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
    at scala.App$class.main(App.scala:76)
    at fdic.LoadBankReferenceData$.main(LoadBankReferenceData.scala:12)
    at fdic.LoadBankReferenceData.main(LoadBankReferenceData.scala)

using null
=> FAILED

这是代码(在Scala中):

  Class.forName("com.sap.db.jdbc.Driver");  
  val conn = DriverManager.getConnection("jdbc:sap://192.168.1.85:39015/", 
      "SYSTEM", "xxxxx"); 

更新

下面的代码抛出完全相同的错误(这次用Java来排除Scala问题):

Class.forName("com.sap.db.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:sap://192.168.1.85:39015/?databaseName=VBK_BANK_0001", 
          "VBK_BANK_0001", "xxxxxxx"); 

我收到同样的错误:[Cannot connect to host 192.168.1.85:39015 [Connection refused: connect], -813.]

在Elipse中:

enter image description here

1 个答案:

答案 0 :(得分:1)

您似乎尝试连接到HANA的多数据库容器(MDC)设置的SystemDB。由于SystemDB很特殊并且不在索引服务器进程中运行,因此您将使用不同的端口(... 13)连接到它。 但是,通常会想要连接到租户数据库。为此,jdbc URL需要包含数据库的名称作为参数。 HANA文档包含有关详细信息。