Google Apps Script

Class Jdbc

The JDBC service. This supports MySQL, Microsoft SQL Server, and Oracle. For more information, see the guide to JDBC.

Methods

MethodReturn typeBrief description
getCloudSqlConnection(url)JdbcConnectionAttempts to establish a connection to the given Google Cloud SQL URL.
getCloudSqlConnection(url, info)JdbcConnectionAttempts to establish a connection to the given Google Cloud SQL URL.
getCloudSqlConnection(url, userName, password)JdbcConnectionAttempts to establish a connection to the given Google Cloud SQL URL.
getConnection(url)JdbcConnectionAttempts to establish a connection to the given database URL.
getConnection(url, info)JdbcConnectionAttempts to establish a connection to the given database URL.
getConnection(url, userName, password)JdbcConnectionAttempts to establish a connection to the given database using a username and password.
newDate(milliseconds)JdbcDateCreate a date from milliseconds since epoch.
newTime(milliseconds)JdbcTimeCreate a time from milliseconds since epoch.
newTimestamp(milliseconds)JdbcTimestampCreate a timestamp from milliseconds since epoch.
parseDate(date)JdbcDateCreate a date by parsing the SQL date string.
parseTime(time)JdbcTimeCreate a time by parsing the SQL time string.
parseTimestamp(timestamp)JdbcTimestampCreate a timestamp by parsing the SQL timestamp string.

Detailed documentation

getCloudSqlConnection(url)

Attempts to establish a connection to the given Google Cloud SQL URL.

Parameters

NameTypeDescription
urlStringa database URL of the form jdbc:google:rdbms:subname

Return

JdbcConnection — a JdbcConnection object


getCloudSqlConnection(url, info)

Attempts to establish a connection to the given Google Cloud SQL URL.

Parameters

NameTypeDescription
urlStringa database URL of the form jdbc:google:rdbms:subname
infoObjectoptional JavaScript object specifying advanced parameters as defined below

Advanced parameters

NameTypeDescription
connectTimeoutSecondsIntegerconnection timeout in seconds
databaseStringthe database to connect to
instanceStringthe name of a Google SQL Service instance
passwordStringthe user's password
queryTimeoutSecondsIntegerquery timeout in seconds
userStringthe username to pass to the database

Return

JdbcConnection — a JdbcConnection object


getCloudSqlConnection(url, userName, password)

Attempts to establish a connection to the given Google Cloud SQL URL.

Parameters

NameTypeDescription
urlStringa database URL of the form jdbc:google:rdbms:subname
userNameStringthe username to pass to the database
passwordStringthe user's password

Return

JdbcConnection — a JdbcConnection object


getConnection(url)

Attempts to establish a connection to the given database URL.

 
var conn = Jdbc.getConnection('jdbc:mysql://yoursqlserver.example.com:3306/database_name');
 

Parameters

NameTypeDescription
urlStringa database URL of the form jdbc:subprotocol:subname

Return

JdbcConnection — a JdbcConnection object


getConnection(url, info)

Attempts to establish a connection to the given database URL.

 
var conn = Jdbc.getConnection('jdbc:mysql://yoursqlserver.example.com:3306/database_name',
                                {user: 'username', password: 'password'});
 

Parameters

NameTypeDescription
urlStringa database URL of the form jdbc:subprotocol:subname
infoObjectoptional JavaScript object specifying advanced parameters as defined below

Advanced parameters

NameTypeDescription
databaseNameStringthe database to connect to
passwordStringthe user's password
useJDBCCompliantTimeZoneShiftBooleanwhether or not the connection should comply with JDBC rules when converting time zones. The default is false.
userStringthe username to pass to the database

Return

JdbcConnection — a JdbcConnection object


getConnection(url, userName, password)

Attempts to establish a connection to the given database using a username and password.

 
var conn = Jdbc.getConnection('jdbc:mysql://yoursqlserver.example.com:3306/database_name',
                                'username', 'password');
 

Parameters

NameTypeDescription
urlStringa database URL of the form jdbc:subprotocol:subname
userNameStringthe username to pass to the database
passwordStringthe user's password

Return

JdbcConnection — a JdbcConnection object


newDate(milliseconds)

Create a date from milliseconds since epoch.

Parameters

NameTypeDescription
millisecondsIntegermilliseconds since epoch

Return

JdbcDate — a JdbcDate object


newTime(milliseconds)

Create a time from milliseconds since epoch.

Parameters

NameTypeDescription
millisecondsIntegermilliseconds since epoch

Return

JdbcTime — a JdbcTime object


newTimestamp(milliseconds)

Create a timestamp from milliseconds since epoch.

Parameters

NameTypeDescription
millisecondsIntegermilliseconds since epoch

Return

JdbcTimestamp — a JdbcTimestamp object


parseDate(date)

Create a date by parsing the SQL date string.

Parameters

NameTypeDescription
dateStringa string containing a SQL date string

Return

JdbcDate — a JdbcDate object


parseTime(time)

Create a time by parsing the SQL time string.

Parameters

NameTypeDescription
timeStringa string containing a SQL time string

Return

JdbcTime — a JdbcTime object


parseTimestamp(timestamp)

Create a timestamp by parsing the SQL timestamp string.

Parameters

NameTypeDescription
timestampStringa string containing a SQL timestamp string

Return

JdbcTimestamp — a JdbcTimestamp object

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.