|
1 | 1 | package dev.mongocamp.driver.mongodb.jdbc |
2 | 2 |
|
3 | | -import dev.mongocamp.driver.mongodb.Converter |
4 | 3 | import dev.mongocamp.driver.mongodb.bson.BsonConverter |
5 | 4 | import dev.mongocamp.driver.mongodb.database.DatabaseProvider |
6 | 5 | import dev.mongocamp.driver.mongodb.jdbc.statement.MongoPreparedStatement |
| 6 | +import dev.mongocamp.driver.mongodb.json.JsonConverter |
| 7 | +import org.mongodb.scala.bson.collection.immutable.Document |
7 | 8 |
|
8 | | -import java.sql.{ |
9 | | - Blob, |
10 | | - CallableStatement, |
11 | | - Clob, |
12 | | - Connection, |
13 | | - DatabaseMetaData, |
14 | | - NClob, |
15 | | - PreparedStatement, |
16 | | - SQLException, |
17 | | - SQLWarning, |
18 | | - SQLXML, |
19 | | - Savepoint, |
20 | | - Statement, |
21 | | - Struct |
22 | | -} |
| 9 | +import java.sql.{Blob, CallableStatement, Clob, Connection, DatabaseMetaData, NClob, PreparedStatement, SQLException, SQLWarning, SQLXML, Savepoint, Statement, Struct} |
23 | 10 | import java.util.Properties |
24 | 11 | import java.util.concurrent.Executor |
25 | | -import java.{ sql, util } |
| 12 | +import java.{sql, util} |
26 | 13 | import scala.jdk.CollectionConverters._ |
27 | 14 |
|
28 | 15 | class MongoJdbcConnection(databaseProvider: DatabaseProvider) extends Connection with MongoJdbcCloseable { |
@@ -186,23 +173,19 @@ class MongoJdbcConnection(databaseProvider: DatabaseProvider) extends Connection |
186 | 173 | } |
187 | 174 |
|
188 | 175 | override def createClob(): Clob = { |
189 | | - checkClosed() |
190 | | - null |
| 176 | + throw sqlFeatureNotSupported() |
191 | 177 | } |
192 | 178 |
|
193 | 179 | override def createBlob(): Blob = { |
194 | | - checkClosed() |
195 | | - null |
| 180 | + throw sqlFeatureNotSupported() |
196 | 181 | } |
197 | 182 |
|
198 | 183 | override def createNClob(): NClob = { |
199 | | - checkClosed() |
200 | | - null |
| 184 | + throw sqlFeatureNotSupported() |
201 | 185 | } |
202 | 186 |
|
203 | 187 | override def createSQLXML(): SQLXML = { |
204 | | - checkClosed() |
205 | | - null |
| 188 | + throw sqlFeatureNotSupported() |
206 | 189 | } |
207 | 190 |
|
208 | 191 | override def isValid(timeout: Int): Boolean = { |
@@ -237,19 +220,17 @@ class MongoJdbcConnection(databaseProvider: DatabaseProvider) extends Connection |
237 | 220 | override def getClientInfo: Properties = { |
238 | 221 | val properties = new Properties() |
239 | 222 | properties.setProperty("ApplicationName", databaseProvider.config.applicationName) |
240 | | - val document = Converter.toDocument(databaseProvider.config) |
| 223 | + val document = Document(JsonConverter().toJson(databaseProvider.config)) |
241 | 224 | BsonConverter.asMap(document).foreach(entry => properties.setProperty(entry._1, entry._2.toString)) |
242 | 225 | properties |
243 | 226 | } |
244 | 227 |
|
245 | 228 | override def createArrayOf(typeName: String, elements: Array[AnyRef]): sql.Array = { |
246 | | - checkClosed() |
247 | | - null |
| 229 | + throw sqlFeatureNotSupported() |
248 | 230 | } |
249 | 231 |
|
250 | 232 | override def createStruct(typeName: String, attributes: Array[AnyRef]): Struct = { |
251 | | - checkClosed() |
252 | | - null |
| 233 | + throw sqlFeatureNotSupported() |
253 | 234 | } |
254 | 235 |
|
255 | 236 | override def setSchema(schema: String): Unit = { |
|
0 commit comments