我启动Gemfire服务器并将他绑定到以下地址:myserver:10344。 (服务器和定位器启动没有问题)之后我检查GFSH和客户端"脉冲"的连接。所有检查都是成功的。在下一步,我开发了我的Java客户端,无法建立与服务器的连接。
我的项目由Maven构建,具有以下依赖项:
<dependency>
<groupId>com.pivotal.gemfirexd</groupId>
<artifactId>gemfirexd</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>com.pivotal.gemfirexd</groupId>
<artifactId>gemfirexd-client</artifactId>
<version>1.4.1</version>
</dependency>
(所有Gemfire依赖项都从http://dist.gemstone.com/maven/release下载)
代码来源:
package com.mycompany.app;
import java.sql.Connection;
import java.sql.DriverManager;
public class App {
private void connect() {
try {
Class.forName("com.pivotal.gemfirexd.jdbc.ClientDriver");
String x = "jdbc:gemfirexd://myserver:10344/";
System.out.println(x);
final Connection conn = DriverManager.getConnection(x);
System.out.println("Connected ");
conn.close();
System.out.println("Disconnected");
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main( String[] args ) {
new App().connect();
}
}
我得到以下异常:
java.sql.SQLNonTransientConnectionException: A communications error has been detected: Failed after trying all available servers: [], for control URL: myserver[10334].
at com.pivotal.gemfirexd.internal.client.am.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:77)
at com.pivotal.gemfirexd.internal.client.am.SqlException.getSQLException(SqlException.java:401)
at com.pivotal.gemfirexd.internal.client.net.NetConnection.getPreferredServer(NetConnection.java:1554)
at com.pivotal.gemfirexd.internal.client.net.NetConnection.preConnect(NetConnection.java:1902)
at com.pivotal.gemfirexd.internal.client.net.NetConnection.newAgent_(NetConnection.java:2368)
at com.pivotal.gemfirexd.internal.client.am.Connection.<init>(Connection.java:595)
at com.pivotal.gemfirexd.internal.client.net.NetConnection.<init>(NetConnection.java:248)
at com.pivotal.gemfirexd.internal.client.net.NetConnection40.<init>(NetConnection40.java:86)
at com.pivotal.gemfirexd.internal.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(ClientJDBCObjectFactoryImpl40.java:290)
at com.pivotal.gemfirexd.jdbc.ClientDriver.connect(ClientDriver.java:161)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.mycompany.app.App.connect(App.java:15)
at com.mycompany.app.App.main(App.java:27)
Caused by: DisconnectException 08006: A communications error has been detected: Failed after trying all available servers: [], for control URL: myserver[10334].
... 12 more
Caused by: java.sql.SQLNonTransientConnectionException: A communications error has been detected: Connection reset.
at com.pivotal.gemfirexd.internal.client.am.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:77)
at com.pivotal.gemfirexd.internal.client.am.SqlException.getSQLException(SqlException.java:401)
at com.pivotal.gemfirexd.jdbc.ClientDriver.connect(ClientDriver.java:170)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.pivotal.gemfirexd.internal.client.net.NetConnection.getPreferredServer(NetConnection.java:1451)
... 11 more
Caused by: DisconnectException 08006: A communications error has been detected: Connection reset.
at com.pivotal.gemfirexd.internal.client.net.NetAgent.throwCommunicationsFailure(NetAgent.java:527)
at com.pivotal.gemfirexd.internal.client.net.Reply.fill(Reply.java:183)
at com.pivotal.gemfirexd.internal.client.net.Reply.ensureALayerDataInBuffer(Reply.java:222)
at com.pivotal.gemfirexd.internal.client.net.Reply.readDssHeader(Reply.java:324)
at com.pivotal.gemfirexd.internal.client.net.Reply.startSameIdChainParse(Reply.java:1154)
at com.pivotal.gemfirexd.internal.client.net.NetConnectionReply.readExchangeServerAttributes(NetConnectionReply.java:61)
at com.pivotal.gemfirexd.internal.client.net.NetConnection.readServerAttributesAndKeyExchange(NetConnection.java:1013)
at com.pivotal.gemfirexd.internal.client.net.NetConnection.flowServerAttributesAndKeyExchange(NetConnection.java:941)
at com.pivotal.gemfirexd.internal.client.net.NetConnection.flowUSRIDONLconnect(NetConnection.java:796)
at com.pivotal.gemfirexd.internal.client.net.NetConnection.flowConnect(NetConnection.java:580)
at com.pivotal.gemfirexd.internal.client.net.NetConnection.<init>(NetConnection.java:259)
at com.pivotal.gemfirexd.internal.client.net.NetConnection40.<init>(NetConnection40.java:86)
at com.pivotal.gemfirexd.internal.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(ClientJDBCObjectFactoryImpl40.java:290)
at com.pivotal.gemfirexd.jdbc.ClientDriver.connect(ClientDriver.java:161)
... 14 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at com.pivotal.gemfirexd.internal.client.net.Reply.fill(Reply.java:181)
... 26 more
答案 0 :(得分:0)
我看到这是一篇很老的帖子,但万一你还想知道......
您在jdbc网址中指定的端口是指对等成员资格发现端口,而不是客户端端口(默认为1527)。
当你启动定位器时,应该有关于客户端端口号的信息(如果你没有指定,默认是1527)
... 使用对等发现启动GemFireXD定位器:localhost [10334] 在地址localhost / 127.0.0.1 [1527]
启动GemFireXD Locator的网络服务器您的jdbc网址应如下所示:
字符串x =&#34; jdbc:gemfirexd:// myserver:1527 /&#34 ;;