OrientDB http 请求失败...?
OrientDB http request failed...?
我正在尝试在 Java 中执行 "POST" 方法。我使用 OrientDB 方法创建我的输出,如下所示:
"http://xxxxxxxxxxx:2480/command/mydb/sql/CREATE VERTEX V SET name = ' datoAletarorio'"
我需要使用 write 和 flush 方法来发送命令。
我的数据库用这个方法是空的。
我的错误在哪里?这是我的代码:
//...
PrintWriter out = null;
//...
conexion = (HttpURLConnection) url.openConnection();
conexion.setDoOutput(true);
conexion.setRequestMethod("POST");
out = new PrintWriter(conexion.getOutputStream());
conexion.connect();
//...
String cumuloDatos1 = "http://xxxxxxxxxxx:2480/command/mydb/sql/CREATE VERTEX V SET name = ' datoAletarorio'"
out.write(cumuloDatos1);
out.flush();
//..
conexion.disconnect();
提前致谢。
docs 说:
The command-text can appear in either the URL or the content of the
POST transmission. Where the command-text is included in the URL, it
must be encoded as per normal URL encoding.
因此您可能必须 encode the URL 在发送请求之前:
String cumuloDatos1 =
"http://xxxxxxxxxxx:2480/command/mydb/sql/" +
"CREATE%20VERTEX%20V%20SET%20name%20%3D%20%27%20datoAletarorio%27"
无论如何,如果请求无效,您应该会在服务器的日志中看到 400 或类似错误的消息。
我正在尝试在 Java 中执行 "POST" 方法。我使用 OrientDB 方法创建我的输出,如下所示:
"http://xxxxxxxxxxx:2480/command/mydb/sql/CREATE VERTEX V SET name = ' datoAletarorio'"
我需要使用 write 和 flush 方法来发送命令。
我的数据库用这个方法是空的。 我的错误在哪里?这是我的代码:
//...
PrintWriter out = null;
//...
conexion = (HttpURLConnection) url.openConnection();
conexion.setDoOutput(true);
conexion.setRequestMethod("POST");
out = new PrintWriter(conexion.getOutputStream());
conexion.connect();
//...
String cumuloDatos1 = "http://xxxxxxxxxxx:2480/command/mydb/sql/CREATE VERTEX V SET name = ' datoAletarorio'"
out.write(cumuloDatos1);
out.flush();
//..
conexion.disconnect();
提前致谢。
docs 说:
The command-text can appear in either the URL or the content of the POST transmission. Where the command-text is included in the URL, it must be encoded as per normal URL encoding.
因此您可能必须 encode the URL 在发送请求之前:
String cumuloDatos1 =
"http://xxxxxxxxxxx:2480/command/mydb/sql/" +
"CREATE%20VERTEX%20V%20SET%20name%20%3D%20%27%20datoAletarorio%27"
无论如何,如果请求无效,您应该会在服务器的日志中看到 400 或类似错误的消息。