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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:13:42+00:00 2026-06-17T09:13:42+00:00

I’ve made a java program in netbeans which executes different queries in my database.

  • 0

I’ve made a java program in netbeans which executes different queries in my database. I have a problem when I add data in the tables. It inserts data in the first 2 tables but not in the third one too. Here’s the code:

String sql="INSERT INTO  `adresa` (`ID` ,`TARA` ,`JUDET` ,`LOC` ,`CPOSTAL` ,`STRADA` ,`NR` ,`BLOC` ,`SC` ,`APT`) VALUES (?,?,?,?,?,?,?,?,?,?)";
    pst=conn.prepareStatement(sql);
    pst.setString(1, ID.getText());
    pst.setString(2, tara.getText());
    pst.setString(3, judet.getText());
    pst.setString(4, loc.getText());
    pst.setString(5, cpostal.getText());
    pst.setString(6, strada.getText());
    pst.setString(7, nr.getText());
    pst.setString(8, bloc.getText());
    pst.setString(9, sc.getText());
    pst.setString(10, apt.getText());
    pst.execute();

String sql2="INSERT INTO  `pbd`.`buletin` (`CNP` ,`DATAN` ,`SEX` ,`SERIENRB` ,`DATAEMIT` ,`DATAEXP`) VALUES (?,?,?,?,?,?);";
pst.setString(1, CNP.getText());
pst.setString(2, datan.getText());
pst.setString(3, sex.getText());
pst.setString(4, serienrb.getText());
pst.setString(5, dataemit.getText());
pst.setString(6, dataexp.getText());
pst.executeBatch();

String sql3="INSERT INTO  `pbd`.`persoana` (`ID` ,`CNP` ,`NUME` ,`PRENUME` ,`NATIONALITATE` ,`VIU`) VALUES (?,?,?,?,?,?);";
pst.setString(1, ID.getText());
pst.setString(2, CNP.getText());
pst.setString(3, nume.getText());
pst.setString(4, prenume.getText());
pst.setString(5, nationalitate.getText());
pst.setString(6, viu.getText());
pst.executeBatch();

And here are the tables information:

enter image description here

I think the queries are wrong or the concept of the tables but I am not sure. Please tell me what do you think.

  • 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-17T09:13:42+00:00Added an answer on June 17, 2026 at 9:13 am

    You need to change your code for sql2 and sql3 as

    pst.close();
    String sql2="INSERT ...
    pst=conn.prepareStatement(sql2);
    ...
    pst.executeUpdate();
    
    pst.close();
    String sql3="INSERT ...
    pst=conn.prepareStatement(sql3);
    ...
    pst.executeUpdate();
    

    executeBatch is irrelevant in this case, it can only be used for different parameter sets of the same SQL.

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

Sidebar

Related Questions

I have been unable to fix a problem with Java Unicode and encoding. The
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I've tracked down a weird MySQL problem to the two different ways I was
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a reasonable size flat file database of text documents mostly saved in
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.