com.blobcity.db.exceptions.InternalAdapterException:此时无法与数据库通信
com.blobcity.db.exceptions.InternalAdapterException: Unable to communicate with the database at this time
在 Infinitum 数据库上执行基本插入操作时出现以下错误。我确定我拥有数据库 运行,因为我能够连接到它并通过 CLI 对其进行操作。
错误信息是:
Exception in thread "main" com.blobcity.db.exceptions.InternalAdapterException: Unable to communicate with the database at this time
at com.blobcity.db.QueryExecuter.executeQuery(QueryExecuter.java:71)
at com.blobcity.db.QueryExecuter.executeBql(QueryExecuter.java:30)
at com.blobcity.db.CloudStorage.postRequest(CloudStorage.java:728)
at com.blobcity.db.CloudStorage.insert(CloudStorage.java:650)
at com.blobcity.db.CloudStorage.insert(CloudStorage.java:381)
at com.blobcity.Main.main(Main.java:23)
Caused by: java.io.IOException: Server returned HTTP response code: 503 for URL: http://localhost/rest/bquery
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at sun.net.www.protocol.http.HttpURLConnection.run(HttpURLConnection.java:1888)
at sun.net.www.protocol.http.HttpURLConnection.run(HttpURLConnection.java:1883)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1882)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1455)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
at com.blobcity.db.QueryExecuter.executeQuery(QueryExecuter.java:57)
... 5 more
Caused by: java.io.IOException: Server returned HTTP response code: 503 for URL: http://localhost/rest/bquery
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1838)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at com.blobcity.db.QueryExecuter.executeQuery(QueryExecuter.java:55)
... 5 more
我造成错误的主要方法是:
package com.blobcity;
import com.blobcity.db.config.Credentials;
import java.util.Random;
public class Main {
public static void main(String[] args) {
Credentials.init("localhost", "root", "root", "mydb");
Hello hello = new Hello();
hello.setId("1");
hello.setRandom(new Random().nextInt());
hello.insert();
}
}
而我为其创建相应 table 的实体 class 是:
package com.blobcity;
import com.blobcity.db.CloudStorage;
import com.blobcity.db.annotations.Entity;
import com.blobcity.db.annotations.Primary;
@Entity
public class Hello extends CloudStorage{
@Primary
public String id;
public int random;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getRandom() {
return random;
}
public void setRandom(int random) {
this.random = random;
}
}
您在设置 Credentials
时缺少端口号。连接到 Infinitum 数据库的默认端口是 10111
,除非您更改了此端口,否则以下应该可以工作
Credentials.init("localhost:10111", "root", "root", "mydb");
在 Infinitum 数据库上执行基本插入操作时出现以下错误。我确定我拥有数据库 运行,因为我能够连接到它并通过 CLI 对其进行操作。
错误信息是:
Exception in thread "main" com.blobcity.db.exceptions.InternalAdapterException: Unable to communicate with the database at this time
at com.blobcity.db.QueryExecuter.executeQuery(QueryExecuter.java:71)
at com.blobcity.db.QueryExecuter.executeBql(QueryExecuter.java:30)
at com.blobcity.db.CloudStorage.postRequest(CloudStorage.java:728)
at com.blobcity.db.CloudStorage.insert(CloudStorage.java:650)
at com.blobcity.db.CloudStorage.insert(CloudStorage.java:381)
at com.blobcity.Main.main(Main.java:23)
Caused by: java.io.IOException: Server returned HTTP response code: 503 for URL: http://localhost/rest/bquery
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at sun.net.www.protocol.http.HttpURLConnection.run(HttpURLConnection.java:1888)
at sun.net.www.protocol.http.HttpURLConnection.run(HttpURLConnection.java:1883)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1882)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1455)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
at com.blobcity.db.QueryExecuter.executeQuery(QueryExecuter.java:57)
... 5 more
Caused by: java.io.IOException: Server returned HTTP response code: 503 for URL: http://localhost/rest/bquery
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1838)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at com.blobcity.db.QueryExecuter.executeQuery(QueryExecuter.java:55)
... 5 more
我造成错误的主要方法是:
package com.blobcity;
import com.blobcity.db.config.Credentials;
import java.util.Random;
public class Main {
public static void main(String[] args) {
Credentials.init("localhost", "root", "root", "mydb");
Hello hello = new Hello();
hello.setId("1");
hello.setRandom(new Random().nextInt());
hello.insert();
}
}
而我为其创建相应 table 的实体 class 是:
package com.blobcity;
import com.blobcity.db.CloudStorage;
import com.blobcity.db.annotations.Entity;
import com.blobcity.db.annotations.Primary;
@Entity
public class Hello extends CloudStorage{
@Primary
public String id;
public int random;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getRandom() {
return random;
}
public void setRandom(int random) {
this.random = random;
}
}
您在设置 Credentials
时缺少端口号。连接到 Infinitum 数据库的默认端口是 10111
,除非您更改了此端口,否则以下应该可以工作
Credentials.init("localhost:10111", "root", "root", "mydb");