---
title: "How to Write to a JDBC Database with Google Apps Script: My Adventure with a Pesky Character Limit"
author: "Dmitry Kostyuk"
date: 2023-09-25T20:39:06+00:00
modified: 2023-09-25T20:44:03+00:00
canonical_url: https://pulse.appsscript.info/p/2023/09/how-to-write-to-a-jdbc-database-with-google-apps-script-my-adventure-with-a-pesky-character-limit/
markdown_url: https://pulse.appsscript.info/p/2023/09/how-to-write-to-a-jdbc-database-with-google-apps-script-my-adventure-with-a-pesky-character-limit.md
categories:
  - "Gotchas"
  - "Intermediate"
  - "New IDE"
  - "Solutions"
  - "V8"
tags:
  - "@wildhogsm"
  - "dmitry-kostyuk"
  - "javascript.plainenglish.io"
  - "Medium"
  - "wurkspaces.dev"
featured_image: https://pulse.appsscript.info/files/2023/09/0_AAfKjH2nFgn31LNP.png
description: "Here's a valuable contribution from Dmitry Kostyuk for anyone who wants to learn how to overcome the 32,768 character limit in Google Apps Script when writing to a JDBC MySQL database. The trick is instead of a single SQL statement use the prepareStatement method with setString. Dmitry's post includes a useful snippet with some functions that makes it easier to handle large SQL statements. Follow the link to the source post for more details."
---

# How to Write to a JDBC Database with Google Apps Script: My Adventure with a Pesky Character Limit

![How to Write to a JDBC Database with Google Apps Script: My Adventure with a Pesky Character Limit](https://pulse.appsscript.info/files/2023/09/0_AAfKjH2nFgn31LNP.png)

> I recently faced a frustrating issue when writing data to a CloudSQL database with the `JDBC` class in Apps Script. I kept getting the following error:
> 

```
<span id="669d" class="ads adt xt ado b mo adu adv l zd adw" data-selectable-paragraph="">Exception: Argument too large: SQL</span>
```

> I also observed that it only happened when my SQL query reached a certain length. I considered breaking it down into multiple queries, but I was still puzzled 🤔 because I was only sending a few dozen kilobytes of data.
> Now, the thing is, the official documentation could be more helpful; even though the solution is there, it needs to be better explained. So, I turned to StackOverflow. There was a discussion on this exact topic, but to my surprise, I was still waiting for an answer. Until, well, [I wrote it](https://stackoverflow.com/questions/67980441/override-google-apps-script-32768-characters-limit-on-exception-argument-too-la.) 😉

*Source: [How to Write to a JDBC Database with Google Apps Script: My Adventure with a Pesky Character Limit*](https://javascript.plainenglish.io/how-to-write-to-a-jdbc-database-with-google-apps-script-my-adventure-with-a-pesky-character-limit-76a674011d8?sk=fe349cd80b05c25aa0c21acf7cebce6f)

---

*Published by [Dmitry Kostyuk](https://pulse.appsscript.info/p/author/dmitrykostyuk/) on [Pulse](https://pulse.appsscript.info/). Original article: [https://pulse.appsscript.info/p/2023/09/how-to-write-to-a-jdbc-database-with-google-apps-script-my-adventure-with-a-pesky-character-limit/](https://pulse.appsscript.info/p/2023/09/how-to-write-to-a-jdbc-database-with-google-apps-script-my-adventure-with-a-pesky-character-limit/)*
