Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8852871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:30:32+00:00 2026-06-14T13:30:32+00:00

I made a script for connecting to database and changing data in specific column

  • 0

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}"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:30:34+00:00Added an answer on June 14, 2026 at 1:30 pm

    Something like this should work:

    def newValue = '01'
    
    new File( '/path/to/data.input' ).with { file ->
      file.withReader { reader ->
        new Scanner( reader ).useDelimiter( ';' ).with { scanner ->
          while( scanner.hasNext() ) {
            sql.executeUpdate "UPDATE tablename SET column=$newValue WHERE number=${scanner.nextInt()}"
          }
        }
      }
      file.renameTo( new File( file.parent, "${file.name}.bak" ) )
    }
    

    Obviously, you probably want to do it in a transaction, or a batch, but this should give you the idea

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've made script which change information from different site, its occure when i click
I made a script that crawls through a domain, and I want it to
I have made a php script to pull from two different tables within the
I am creating tables in a SQLite database from a database dump made by
I have a jquery script that collects data from different sites and saves it
I have ajax call which pulls from the processing script 'getajax.php'. Call is made
I made a script that spawns a remote shell or runs a local shell
i made a script that dynamically loads content into a div and whenever the
I have made a script, but it's not working as expected, and I need
I've made a script which copies the alt attribute of an image and puts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.