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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:38:43+00:00 2026-06-01T10:38:43+00:00

While I perform insertion in the db table, the exception occurs, which says: Data

  • 0

While I perform insertion in the db table, the exception occurs, which says:

Data truncation error in mySQL while inserting data..

At:->

com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'branchname' at row 1

the column type is varchar

JSP:

<form action="BranchServlet" method="post">
<table align="center">
<tr>
<td align="center" colspan="2"><hr>Add Branch Details<hr></td>
</tr>


<tr>
<td align="left">Branch Name</td>
<td align="center"><input type="text" name="branchname"></td>
</tr>
<tr>
<td align="left">Branch Code</td>
<td align="center"><input type="text" name="branchcode"></td>
</tr>
<tr>
<td align="center">

</td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" Value="Submit"></td>
</tr>
</table>
</form>

Servlet:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
    {

        String bname = request.getParameter("branchname");
        String bcode = request.getParameter("branchcode");

        BranchModel bm = new BranchModel();
        BranchDAO bd = new BranchDAO();

        bm.setBranchcode(bcode);
        bm.setBranchname(bname);

        bd.insert(bm);

        response.sendRedirect("branches.jsp");
    }

DAO Method:

public void insert(BranchModel m)
    {
        try{
            Class.forName(driver);
            con = DriverManager.getConnection(url+db,"root","root");
            Statement st = con.createStatement();

            st.executeUpdate("insert into branches values('"+m.getBranchcode()+"','"+m.getBranchname()+"')");
            System.out.println("record inserted");
        }catch(Exception e)
        {
            e.printStackTrace();
        }
    }
  • 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-01T10:38:44+00:00Added an answer on June 1, 2026 at 10:38 am

    You said the column is of type varchar, but not what size varchar. This seems to be the root of your problem. I don’t see any validation enforcing a limit on the size of the text input. The input validations need to limit input size the size of the corresponding varchar column.

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

Sidebar

Related Questions

I have to do a background process which will perform some operations.. while this
I've gotten the next error while trying to perform some bunch deletion with reasonable
Now while I know that you can not perform inheritance like you would in
I would like to perform a measurement and plot a graph while the measurement
I have written code to perform a function that could take a while to
What does the following function perform? public static double CleanAngle(double angle) { while (angle
While developing a web application I want to perform certain validation check and only
Once in a while, I need to perform a massive update to a very
Yesterday I was working on a shell script to perform some moderately complex table
i have a database table prop_amenities which have following columns here is the create

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.