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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:49:38+00:00 2026-05-30T11:49:38+00:00

I have to build a insert query string for creating a Prepared Statement. I

  • 0

I have to build a insert query string for creating a Prepared Statement. I have all the column name in Excel file.

There are more than 250 column in table, it takes much time and effort to create a simple insert query. I have to count the columns and put ? in values field in query.

Is there any other way to create these query.

Please Suggest.
Thanks In Advance

  • 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-30T11:49:40+00:00Added an answer on May 30, 2026 at 11:49 am

    I can suggest a paradigm of doing this , implementing it would be a much larger issue though and from what I can make out , this is a pretty involved task !

    You can use the JXL api to read these column names, you can also store their types in the same excel file (this will be useful when you are preparing the statement).

    So your excel will be :

    Column 1 | Integer
    Column 2 | String
    Column 3 | Date 
    

    and so on

    JXL will allow you to read all this into your java program, store this information in a Map (java.util.HashMap) , so at this point you have the names of columns in your program and their data types.

    Now , about creating the prepared statement.

    String allColumnNames ="";
    foreach element in the hashmap, allColumnNames+=getKey() + ","
    

    so at this point allColumnNames has all your column names

    Make the prepared statement in segments :

    String statement = "insert into table ("+ allColumnNames +") values " + <250 ? marks here>;
    

    There goes your prepared statement.

    After this ,to insert stuff, you can iterate through the hashmap again and call setString or setInt or whatever depending on the “value” part of the hashmap.

    As I said , its a long and involved process , but you can even modify this procedure to just set values in the excel file and then insert them directly from the excel into your table.

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

Sidebar

Related Questions

We have to build Strings all the time for log output and so on.
I have query build from Visual Studio 2005. I am inserting records from SQL
I want to build a query to insert photo details in database tables. Here's
I have job insert page which is working fine. I just build an update
I am trying to build a query such that some column are built up
I have a query that uses a lot of aggregate functions to build data
Currently I have some event listeners setup to log all insert/update/delete actions that happen.
I have build server inside our domain (and it needs to be because it
I have build C# program that work with RAPI (communication to PPC or WinCE)
I have build a webapplication using ASP.NET MVC and JQuery. On my local machine

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.