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

  • SEARCH
  • Home
  • 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 527505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:53:24+00:00 2026-05-13T08:53:24+00:00

how can i replace hardcoded number with variable in this java statement which is

  • 0

how can i replace hardcoded number with variable in this java statement which is accessing the mysql datatabase using jdbc. the query is executed using executeQuery(query)

here is the java statement

String query = "select * from TableA where num = '1233' ";

i need to replace this 1233 with a variable in this statement.

any help appreciated

Regards,

  • 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-05-13T08:53:24+00:00Added an answer on May 13, 2026 at 8:53 am

    If you can use prepared statement, you’ll be safer (no risk of SQL injection):

        Connection con = getMyConnection();
        try {
            PreparedStatement ps = con.prepareStatement("select * from TableA where num = ?");
            try {
                ps.setLong(1, number);
                ResultSet rs = ps.executeQuery();
                while(rs.next()) {
                    //TODO
                }
            } finally {
                ps.close();
            }
        } finally {
            con.close();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 515k
  • Answers 516k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer <?php if ( have_posts() ) : $slideNumber = 1; while… May 16, 2026 at 6:41 pm
  • Editorial Team
    Editorial Team added an answer The problem is that the transformation you are using does… May 16, 2026 at 6:41 pm
  • Editorial Team
    Editorial Team added an answer select t.patient_id, max(t.visit_id) from (select t.patient_id, max(t.visit_date) maxdate from table… May 16, 2026 at 6:40 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I want to replace the hard coded string Categories with a variable. How can
I'm building a set of SVG files that include an unfortunate number of hardcoded
I am somewhat new to R, and i have this piece of code which
Is there a data structure that can replace the following two maps: Dictionary<TypeA, TypeB>
I need to group data held in a list but can’t hardcode the groupBy
$(#commentForm).validate({ rules: { insurance1$ucBuildingInsurance$txtOtherReasonDescription: required } }); My current script looks like this to
$(#bc [id$=_dropdownID]).change(function() { if (this.value == '2' || this.value == '3') { $(#bc .pnl).show();
What is a good collection/container to use for basically storing the contents of a
I have a SharePoint DLL that does some licensing things and as part of
I want to base64 encode data to put it in a URL and then

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.