title: Connecting to database and getting some info from db in Katalon Studio
body: <p>I'm trying to connect to my database and get from there some info in Katalon Studio, but for some reason it doesn't work.</p>
  
  <p>I've made an db connection keyword for connection and then I use it in my script.</p>
  
  <pre><code>package db_connection
  
  import com.kms.katalon.core.util.KeywordUtil
  
  import groovy.sql.Sql
  
  public class SQLHandler_Con {
      String dbConnString = "jdbc:sqlserver://testapdb\\TEST;databaseName=2007"
      String dbUsername = "testuser"
      String dbPassword = "Password!"
      String dbDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
  
      Sql sql = Sql.newInstance(dbConnString,dbUsername,dbPassword,dbDriver)
  
      public List getSelectResults(String query) {
          KeywordUtil.logInfo("Executing the query: " + query)
          List results = sql.rows(query)
          if(results.size() == 0) {
              KeywordUtil.markFailedAndStop("No rows returned from SQL Server")
          }
          return results
      }
  
      public void closeConn() {
          sql.close()
      }
  }
  </code></pre>
  
  <p>This is my SQLHandler and other script looks like that</p>
  
  <pre><code>public class database_Selector {
  
      @Keyword
      def getResource() {
          SQLHandler_Con sql = new SQLHandler_Con()
          List&lt;GroovyRowResult&gt; res = sql.getSelectResults('SELECT TOP 100 PERSONAL_ID, PHONE2, SMS_MOBILE_PHONE FROM CLIENTS WHERE PERSONAL_ID IS NOT NULL AND PHONE2 IS NOT NULL AND SMS_MOBILE_PHONE IS NOT NULL ')
          int countFromDb = res.get(0).get('clients')
          println("No. of rows in Database is(are):" + res.get(0))
          return countFromDb
      }
  }
  </code></pre>
  
  <p>And when I try to run this </p>
  
  <pre><code>def database_count = CustomKeywords.'db_connection.databaseSelector.getResource'()
  println(database_count)
  </code></pre>
  
  <p>it gives me an error: database_count = db_connection.database_Selector.getResource() FAILED.</p>
  
  <p><strong>EDIT:</strong> I've edited my code and now it works, but if you have an ideas how can i get table from database, can you tell me ? My script was written only for getting count.</p>
  
  <pre><code>SELECT COUNT(*) as Clients FROM CLIENTS WHERE PERSONAL_ID IS NULL AND PHONE2 IS NOT NULL AND SMS_MOBILE_PHONE IS NULL
  </code></pre>
  
  <p>But I want to perform different action.</p>