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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:26:52+00:00 2026-06-11T00:26:52+00:00

im a beginner in java servlet my problem is i want to generate a

  • 0

im a beginner in java servlet my problem is i want to generate a account no . eachtime there would be a new account on my table.but the trigger is not workin pls help the othe values like fname lname username and pword etc are workin fine the servlet is ok but the trigger for creating the accno is not workin properly

CREATE OR REPLACE TRIGGER T1 BEFORE INSERT ON UINFO
FOR EACH ROW
BEGIN
set new.UACCNO="jith"||to_char(SQ_1.nextval,'FM0009');
END;
/

//this is my servlet prog

String s1=hreq.getParameter("fname");
            String s2=hreq.getParameter("lname");
            String s3=hreq.getParameter("uacc");
            String s4=hreq.getParameter("uname");
            String s5=hreq.getParameter("pword");
            String s6=hreq.getParameter("pword2");
            String s7[]=hreq.getParameterValues("select");
            String s8=hreq.getParameter("uans");
            String s9=hreq.getParameter("ueid");
            PrintWriter pw=hres.getWriter();

    //if passwords match        

        if(s6.equals(s5))
        {

            PreparedStatement pstmt=con.prepareStatement("insert into uinfo(fname,lname,uacc,uname,pword,uques,uans,ueid) values(?,?,?,?,?,?,?,?)");
pstmt.setString(1,s1);
pstmt.setString(2,s2);
pstmt.setString(3,s3);
pstmt.setString(4,s4);
pstmt.setString(5,s5);
for(int i=0;i<s7.length;i++)
{
if(s7[i]!=null)
pstmt.setString(6,s7[i]);

}
pstmt.setString(7,s8);
pstmt.setString(8,s9);
pstmt.executeUpdate();
pw.println("<html><body  bgcolor=wheat text=blue>");
pw.println("<h1>user  "+s4+"  has Registered successfully</h1><br/><br/>");
pw.println("<h3><a href=login.html>Login Now?</a></h3>");
 pw.println("</body></html>");
 }
 else
 {
            pw.println("<html><body  bgcolor=wheat text=blue>");
            pw.println("<h1>**the passwords do not match go back and check</h1>");
            pw.println("</body></html>");
    }
  • 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-11T00:26:53+00:00Added an answer on June 11, 2026 at 12:26 am

    Using a Trigger to create a consecutive for a record is overkill, you should call the sequence from another PreparedStatement, like this:

    PreparedStatement statement = con.prepareStatement( "SQ_1.nextval from dual")  
    

    Then after pulling out the consecutive, do the required transformation to create your key and pass it in the insert statement.

    Another option you have is directly passing the SQ_1.nextval in the insert statement, but this might depend on the db engine you are using.

    If it’s oracle as I suspect, It would be like this (please note the example below is not doing the concatenation/transforming you do in the trigger, I leave that up to you):

    PreparedStatement pstmt=con.prepareStatement(
    "insert into uinfo(UACCNO,fname,lname,uacc,uname,pword,uques,uans,ueid) values(SQ_1.nextval,?,?,?,?,?,?,?,?)");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For the record, I'm NOT a Java Beginner, but -- rather - an intermediate-level
I'm a beginner in Java. I want to use StringUtils.replace but Eclipse outputs StringUtils
Iam a Java beginner and i would like to ask whats the pros and
I am a Java beginner and, I am not really sure what JMSExceptions are
I am a Java beginner and I would appreciate it if someone here can
I'm Java beginner, but I thought that when using try-catch-finally I don't have to
I am beginner in java mobile, I download Wireless Toolkit 2.5.2 as emulator but
I am a Java beginner , I want to develop Android app , what
I'm a beginner java developer and i'm not very confident with java world tools.
I am a crazy Java beginner, FYI. I want to compile a program (actually

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.