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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:50:37+00:00 2026-06-03T02:50:37+00:00

I am trying to add a column to a database table and PreparedStatement ps

  • 0

I am trying to add a column to a database table and

PreparedStatement  ps = con.prepareStatement(query);  
ps.execute();
ps.close();

query is something like (valid SQL)

ALTER TABLE mytable ADD COLUMN mycolumn datatypeinfo

Anyway, it executes fine and the column is created. But the execute statement returns false. I tried with executeUpdate and that returns 0 rows.

Note that this whole thing is within a transaction with con.setAutoCommit set to false. So I am not sure if that is the problem. The issue is that I have to create the column before I can go ahead with other update queries. So it has to run in a transaction.

  • 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-03T02:50:38+00:00Added an answer on June 3, 2026 at 2:50 am

    The return value of execute() does not indicate whether it was successful, but if the query that was run returned a result.

    As the ALTER TABLE does not return a result, the execute() rightfully returns false

    Quote from the Javadocs:

    Returns: true if the first result is a ResultSet object; false if the first result is an update count or there is no result

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

Sidebar

Related Questions

I am a NOVICE SQL ADMIN... I am trying to add a column 'ID'
I’m trying to select various table and column names from a (SQL Server 2008)
I am trying to add something to my database but I keep getting an
I am trying to implement a search function on a database table using query
I am upgrading my database to add another column. What I am trying to
Table entity column is unique, and I'm trying to add items. Items amount is
I'm trying to add a custom filter to my RadGrid. I have a column,
I'm just trying to add 2 columns to customer table alter table CUSTOMER ADD
Im trying to add an element to a database and then return a new
I have recently added a new column (age) to a database table (user). I

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.