Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8337783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:23:43+00:00 2026-06-09T04:23:43+00:00

I connect remotely to my database with Squirrel (with jTDS), so I think I

  • 0

I connect remotely to my database with Squirrel (with jTDS), so I think I have my parameters set properly. GAS gives me systematically an error: “failed to establish a database connection”. Any way to debug that bad connection? My code is from the GAS JDBC example, but I am using mssql.

Any suggestions?

Note: I tried the following as well, because that us how I enter it in Squirrel:

  var conn = Jdbc.getConnection("jdbc:sqlserver:///my.server.adress:2433/MyName", "MyName", "password");

Stuck!

function foo() {
  var conn = Jdbc.getConnection("jdbc:sqlserver:///my.server.adress:2433", "MyName", "password");
  var stmt = conn.createStatement();
  stmt.setMaxRows(100);
  var start = new Date();
  var rs = stmt.executeQuery("select * from MyTable");

  var doc = SpreadsheetApp.getActiveSpreadsheet();
  var cell = doc.getRange('a1');
  var row = 0;
  while(rs.next()) {
    cell.offset(row, 0).setValue(rs.getString(1));
    cell.offset(row, 1).setValue(rs.getString(2));
    cell.offset(row, 2).setValue(rs.getString(3));
    cell.offset(row, 3).setValue(rs.getString(4));
    row++;
  }
  rs.close();
  stmt.close();
  conn.close();
  var end = new Date();
  Logger.log("time took: " + (end.getTime() - start.getTime()));
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:23:44+00:00Added an answer on June 9, 2026 at 4:23 am

    This is the complete function (it works!), with USE:

      function typestring_f() {
      var conn = Jdbc.getConnection("jdbc:sqlserver://my.server.adress:2433", "MyName", "password");
      var stmt = conn.createStatement();
    
      var ret = stmt.execute("USE wgwDatabase;");
    
      pstmt=conn.prepareStatement("{ call f_dict_sp(?)}");  // get the stored procedure with 1 parameter.
      pstmt.setString(1, "cat%"); // set the parameter (a string for matching with Like )
      pstmt.setMaxRows(100);
      rs= pstmt.executeQuery(); // run the query
    
      var doc = SpreadsheetApp.getActiveSpreadsheet();
      var cell = doc.getActiveRange(); // ac('a1');
      var row = 0;
      while(rs.next()) {
        cell.offset(row, 0).setValue(rs.getString(1));
        cell.offset(row, 1).setValue(rs.getString(2));
        row++;
      }
      rs.close();
      pstmt.close();
      conn.close();
    
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i keep getting this error when trying to connect to my database remotely.
I am attempting to remotely connect to a MySQL database using ruby on rails.
I'm trying to connect to my DB in Ubuntu remotely but I receive error
I have a pgsql server running on windows 7. I can remotely connect to
How do I connect to an SQL Server remotely and administer my database objects?
I have two servers (virtual machines - I can remotely connect to these) -
For a thick-client project I'm working on, I have to remotely connect to a
I connect to SQL Server database and grab a DataSet of the result with
I connect to a mysql database using pymysql and after executing a request I
To connect signals to slots, as far as I know, the parameters of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.