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 4533992
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:13:31+00:00 2026-05-21T14:13:31+00:00

How to replace single quote in Java with Postgres? select * from where id

  • 0

How to replace single quote in Java with Postgres?

select * from where id in ('<45646300.KDSFJJSKJSDF95'fdgdfgdfgd>', 'fdgdfgdg');

I always use params like

select * from where id = ?;

But in this case i have problem, where i have ‘in’ statement with string passed to it.

I wish to replace all dangerous chars

  • 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-21T14:13:31+00:00Added an answer on May 21, 2026 at 2:13 pm

    It would be better to continue using PreparedStatements rather than to escape characters manually.

    In the case of IN clause you can generate a query with appropriate number of ?s dynamically.

    String[] input = ...;
    
    StringBuilder b = new StringBuilder();
    b.append("select * from where id in (");
    b.append("?"); // Assume that input contains at least one element
    for (int i = 1; i < input.length; i++) b.append(", ?");
    b.append(")");
    
    PreparedStatement s = c.prepareStatement(b.toString());
    
    for (int i = 0; i < input.length; i++) s.setString(i + 1, input[i]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I replace single-quote (') with double-quote () in sql query - oracle
I want to replace single quote (') in a string. Apparently this will not
How do I use string.tr to replace double quotes with single ones in Ruby?
I'm trying to write a regex function that will identify and replace a single
I would like to replace only the group in parenthesis in this expression :
I have this function in SQL Server to replace single quotes. But when I
How can I replace lone instances of \n with \r\n (LF alone with CRLF)
I'm looking to replace a couple of machines in the office with a more
$output = preg_replace(|(/D)(/s+)(/d+)(;)|, //1,//3;, $output); I'm trying to replace all alphabetical character followed by
We need to replace the menu system in our main ASP.NET application. So naturally

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.