|
1 | 1 | /* |
2 | 2 | * DBeaver - Universal Database Manager |
3 | | - * Copyright (C) 2010-2024 DBeaver Corp and others |
| 3 | + * Copyright (C) 2010-2025 DBeaver Corp |
4 | 4 | * |
5 | | - * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | - * you may not use this file except in compliance with the License. |
7 | | - * You may obtain a copy of the License at |
| 5 | + * All Rights Reserved. |
8 | 6 | * |
9 | | - * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | - * |
11 | | - * Unless required by applicable law or agreed to in writing, software |
12 | | - * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | - * See the License for the specific language governing permissions and |
15 | | - * limitations under the License. |
| 7 | + * NOTICE: All information contained herein is, and remains |
| 8 | + * the property of DBeaver Corp and its suppliers, if any. |
| 9 | + * The intellectual and technical concepts contained |
| 10 | + * herein are proprietary to DBeaver Corp and its suppliers |
| 11 | + * and may be covered by U.S. and Foreign Patents, |
| 12 | + * patents in process, and are protected by trade secret or copyright law. |
| 13 | + * Dissemination of this information or reproduction of this material |
| 14 | + * is strictly forbidden unless prior written permission is obtained |
| 15 | + * from DBeaver Corp. |
16 | 16 | */ |
17 | 17 | package com.dbeaver.jdbc.driver.libsql.client; |
18 | 18 |
|
19 | 19 | import com.dbeaver.jdbc.driver.libsql.LibSqlConstants; |
20 | | -import com.google.gson.Gson; |
21 | | -import com.google.gson.GsonBuilder; |
22 | | -import com.google.gson.Strictness; |
23 | | -import com.google.gson.ToNumberPolicy; |
| 20 | +import com.google.gson.*; |
24 | 21 | import com.google.gson.stream.JsonWriter; |
25 | 22 | import org.jkiss.code.NotNull; |
26 | 23 | import org.jkiss.code.Nullable; |
27 | 24 | import org.jkiss.utils.CommonUtils; |
28 | 25 |
|
29 | | -import java.io.*; |
| 26 | +import java.io.IOException; |
| 27 | +import java.io.StringReader; |
| 28 | +import java.io.StringWriter; |
| 29 | +import java.io.Writer; |
30 | 30 | import java.net.CookieManager; |
31 | 31 | import java.net.HttpURLConnection; |
32 | 32 | import java.net.URL; |
@@ -113,14 +113,19 @@ public LibSqlExecutionResult[] executeBatch( |
113 | 113 | ); |
114 | 114 | try { |
115 | 115 | String responseBody = httpResponse.body(); |
116 | | - try (Reader isr = new StringReader(responseBody)) { |
| 116 | + try (StringReader isr = new StringReader(responseBody)) { |
117 | 117 | Response[] response; |
118 | 118 | if (responseBody.startsWith("[")) { |
119 | 119 | response = gson.fromJson(isr, Response[].class); |
120 | 120 | } else { |
121 | | - response = new Response[] { |
122 | | - gson.fromJson(isr, Response.class) |
123 | | - }; |
| 121 | + Response parsedResponse; |
| 122 | + try { |
| 123 | + parsedResponse = gson.fromJson(isr, Response.class); |
| 124 | + } catch (JsonSyntaxException e) { |
| 125 | + parsedResponse = new Response(); |
| 126 | + parsedResponse.error = responseBody; |
| 127 | + } |
| 128 | + response = new Response[] { parsedResponse }; |
124 | 129 | } |
125 | 130 | LibSqlExecutionResult[] resultSets = new LibSqlExecutionResult[response.length]; |
126 | 131 | for (int i = 0; i < response.length; i++) { |
|
0 commit comments