You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2021/06/08 02:24:52 UTC

[incubator-nlpcraft] branch NLPCRAFT-296 updated: Update SqlAccess.scala

This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch NLPCRAFT-296
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-296 by this push:
     new a82e315  Update SqlAccess.scala
a82e315 is described below

commit a82e315fef21ad86449ada698ab60ad0261faa9d
Author: unknown <ar...@datalingvo.com>
AuthorDate: Mon Jun 7 19:24:44 2021 -0700

    Update SqlAccess.scala
---
 .../main/java/org/apache/nlpcraft/examples/sql/db/SqlAccess.scala  | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/nlpcraft-examples/sql/src/main/java/org/apache/nlpcraft/examples/sql/db/SqlAccess.scala b/nlpcraft-examples/sql/src/main/java/org/apache/nlpcraft/examples/sql/db/SqlAccess.scala
index 80a3847..b960419 100644
--- a/nlpcraft-examples/sql/src/main/java/org/apache/nlpcraft/examples/sql/db/SqlAccess.scala
+++ b/nlpcraft-examples/sql/src/main/java/org/apache/nlpcraft/examples/sql/db/SqlAccess.scala
@@ -18,13 +18,14 @@
 package org.apache.nlpcraft.examples.sql.db
 
 import java.sql.{Connection, PreparedStatement, SQLException}
-
 import com.github.vertical_blank.sqlformatter.SqlFormatter
 import com.typesafe.scalalogging.LazyLogging
 import org.apache.nlpcraft.common.ascii.NCAsciiTable
 import org.h2.jdbc.JdbcSQLException
 import org.h2.jdbcx.JdbcDataSource
 
+import scala.util.Using
+
 /**
   * Ad-hoc querying for H2 Database. This is a simple, single thread implementation.
   */
@@ -70,10 +71,10 @@ object SqlAccess extends LazyLogging {
         }
 
         try {
-            managed { getPs } acquireAndGet { ps =>
+            Using.resource { getPs } { ps =>
                 qry.parameters.zipWithIndex.foreach { case (p, idx) => ps.setObject(idx + 1, p) }
 
-                managed { ps.executeQuery() } acquireAndGet { rs =>
+                Using.resource { ps.executeQuery() } { rs =>
                     val md = rs.getMetaData
                     val cnt = md.getColumnCount