I made a script for connecting to database and changing data in specific column for definitely number.
Now i want read a numbers from text file with specific extension, making changes for those numbers in database and then rename file with .bak extension.
help me, please. i appreciate your help in advance!
import groovy.sql.Sql
sql = Sql.newInstance('jdbc:mysql://localhost:3306/database', 'login', 'password', 'com.mysql.jdbc.Driver')
int rowsAffected = sql.executeUpdate('update tablename set column = '01' where number=$NumberFromFile')
println "updated: ${rowsAffected}"
Something like this should work:
Obviously, you probably want to do it in a transaction, or a batch, but this should give you the idea