Ok so i'll demonstrate my problem on tutorial code from https://developers.google.com/apps-script/jdbc
function insert() {
var conn = Jdbc.getConnection("jdbc:mysql://<host>:<port>/<instance>", "user", "password");
conn.setAutoCommit(false);
var stmt = conn.prepareStatement("insert into person (lname,fname) values (?,?)");
var start = new Date();
for (var i = 0; i < 5000; i++) {
// Objects are accessed using 1-based indexing
stmt.setObject(1, 'firstName' + i);
stmt.setObject(2, 'lastName' + i);
stmt.addBatch();
}
var res = stmt.executeBatch();
conn.commit();
conn.close();
var endTime = new Date();
Logger.log("time is " + (endTime.getTime() - start.getTime()) + "ms");
Logger.log("res has " + res.length);
}
Im from slovakia and we have special characters like žťščľýá after i change this line
stmt.setObject(1, 'firstName' + i);
to
stmt.setObject(1, 'žťščľýá' + i);
I'll get ???? in my db.I have utf8_general_ci in my db and my table picture
I've seen this JDBC Service with MySQL : UTF-8 encoding / decoding and tried Utilities.newBlob("").setDataFromString("foo", "UTF-8").getDataAsString("UTF-16")
also this JDBC character encoding where lot of people are suggesting to use ?characterEncoding=utf8
after my connection link but i'll get error message.