【EasyClick】【通用】mysql jdbc删除数据delete示例
function main() {//mysql 的地址ip:端口/数据库名
let mysqlUrl = "jdbc:mysql://10.0.0.112:3306/test?characterEncoding=utf8&autoReconnect=true"
let inited = jdbc.init("com.mysql.jdbc.Driver", mysqlUrl, "test", "test123")
logd("inited " + inited)
let conn = jdbc.connect()
logd("connect " + conn)
if (!conn) {
logd(jdbc.getLastError())
exit()
}
logd("start")
//更新数据
let q = "delete frommomo where id=?;"
let qur = jdbc.createPreparedStatement(q)
if (qur) {
//设置id
jdbc.psqlSetInt(1, 1)
}
let rowcount = jdbc.psqlExecuteUpdate()
logi("插入语句执行影响行数 -> " + rowcount)
if (rowcount <= 0) {
loge("插入错误: " + jdbc.getLastError())
}
jdbc.psqlClose()
jdbc.connectionClose()
}
页:
[1]