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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:01:43+00:00 2026-06-07T18:01:43+00:00

I am making an application in NetBeans (java). This application has unique id combination

  • 0

I am making an application in NetBeans (java). This application has unique id combination of string and integer like abc/111 or xyz/253 and the integer part should increase by when a new entry takes place in the database i.e. abc/112 and xyz/254.

The problem is the value of integer part increase until it has reached 10 in a proper way but after that it does not increase and remain same for further entries in database.

I used the following code –

try{
    String sql = "SELECT RegNumber FROM Death ORDER BY RegNumber DESC   ";
    pst = conn.prepareStatement(sql);

    rs = pst.executeQuery();

    if (rs.next()) {

        String add1 = rs.getString("RegNumber");
        String[] parts= add1.split("/");
        String part1= parts[0];
        String part2= parts[1];
        int a,b;
        a= Integer.parseInt(part2);
        b=a+1;

        jTextField20.setText(""+part1+"/"+b);


        JOptionPane.showMessageDialog(null, "done");
    }
   }

“Integer part increase till 10” means that if I start the first value of id in database like abc/1 then new id generates automatically for the next entry with the increasing value 1 that is abc/2 and for next entry it is abc/3 and so on in sequential order like this: abc/4, …, abc/10

But when it has reached abc/10 the new generated id remains same i.e. abc/10 for every new entry in database. (I am using MS Access 2007 and the id is of text type). The first id in the database is created by the application itself.

If anyone has another alternative to generate id, please tell me.

  • 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-07T18:01:46+00:00Added an answer on June 7, 2026 at 6:01 pm

    The problem is that

    String sql = "SELECT RegNumber FROM Death ORDER BY RegNumber DESC   ";
    

    will sort on descending alphabetic order, and alphabetically speaking

    "abc/9" > "abc/10"
    

    and that’s why your program always fetches 9 over and over again…

    I think you will have to split up that column for storage, and store the numeric part as an actual number type in the database. That’s probably not as hard as it sounds, you can always sort on 2 fields

    String sql = "SELECT RegNumber FROM Death ORDER BY RegString DESC, RegNumber DESC   ";
    

    You could also consider using a SERIAL (autoincrement) datatype for the RegNumber part in certain cases (ie if RegNumber is not reset eg when the string part changes) to simplify your insertion logic further.

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

Sidebar

Related Questions

I m making Desktop Application in netbeans plpatform in java swing.when i run my
I am making a Java Desktop Application using Netbeans. I am new to Desktop
I was making a java gui application through netbeans IDE. All was working fine
Im making an application which uses few languages. I would like to have possibility
I developed a Java application in Netbeans, and I'm going to release it soon
I am making in application in .NET (c# .NET) and its kind of like
I am making application in C# which has a byte array containing hex values.
i am making application in c#. In that implication i have string which contain
I am making a application where i would like to log in with a
I'm making an application for Android, on the Splash screen I would like it

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.