S.E.
S.E.

Reputation: 1

Using Integrated security for DB connection in Google Docs Script?

I want to establish a connection to MS SQL in Google docs via Script by using integrated security = SSIP, basically connecting to the server with my integrated Windows authentication. However, Google tells me that the 'integrated security' connection property is unsupported. I tried phrasing it differently (trusted_security etc.) but nothing works.

Does anyone know a workaround?

I used the query google offered below.

// Replace the variables in this block with real values.
var address = 'database_IP_address';
var user = 'user_name';
var userPwd = 'user_password';
var db = 'database_name';

var dbUrl = 'jdbc:mysql://' + address + '/' + db' integrated security = ssip;

// Read up to 1000 rows of data from the table and log them.
function readFromTable() {
  var conn = Jdbc.getConnection(dbUrl, user, userPwd);

  var start = new Date();
  var stmt = conn.createStatement();
  stmt.setMaxRows(1000);
  var results = stmt.executeQuery('SELECT * FROM entries');
  var numCols = results.getMetaData().getColumnCount();

  while (results.next()) {
    var rowString = '';
    for (var col = 0; col < numCols; col++) {
      rowString += results.getString(col + 1) + '\t';
    }
    Logger.log(rowString)
  }

  results.close();
  stmt.close();

  var end = new Date();
  Logger.log('Time elapsed: %sms', end - start);
}

Upvotes: 0

Views: 173

Answers (0)

Related Questions