title: How to insert multiple check boxes values in single column one value in single row in database using jsp
body: <p>I want to store multiple check boxes values in database using JSP in single column of database but single value in single row. 
   My JSP code QuickFunction.jsp:</p>
  
  <pre><code>    &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2 align="center"&gt; Quick Function&lt;/h2&gt;
  
  &lt;form action="QuickServlet"&gt;
                  &lt;table border="1" align="center"&gt;
              &lt;tr&gt;&lt;td width=50 align="center"&gt;1&lt;/td&gt;
              &lt;td&gt;Book A voucher&lt;/td&gt;
              &lt;td&gt;Sales Voucher&lt;/td&gt;
                  &lt;td&gt;&lt;input type="checkbox" name="voucher"
                      value="Sales Voucher" /&gt;&lt;/td&gt;
  
              &lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
              &lt;td&gt;Purchase Voucher&lt;/td&gt;
                  &lt;td&gt;&lt;input type="checkbox" name="voucher"
                      value="Purchase Voucher" /&gt;&lt;/td&gt;
  
              &lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
              &lt;td&gt;Receipt&lt;/td&gt;
                  &lt;td&gt;&lt;input type="checkbox" name="voucher"
                      value="Receipt" /&gt;&lt;/td&gt;
  
              &lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
              &lt;td&gt;Payment &lt;/td&gt;
                  &lt;td&gt;&lt;input type="checkbox" name="voucher"
                      value="Payment" /&gt;&lt;/td&gt;
  
              &lt;/tr&gt;
              &lt;tr&gt;
              &lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt; Contra &lt;/td&gt;
                  &lt;td&gt;&lt;input type="checkbox" name="voucher"
                      value="Contra" /&gt;&lt;/td&gt;
  
              &lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
              &lt;td&gt; Journal &lt;/td&gt;
                  &lt;td&gt;&lt;input type="checkbox" name="voucher"
                      value="Journal"&gt;&lt;/td&gt;
  
              &lt;/tr&gt;
         &lt;/table&gt;
          &lt;input type="submit" value="Submit"/&gt;
       &lt;/form&gt;
       &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>My servlet code QuickServlet (doGet method):</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
          PrintWriter out = response.getWriter();
          String voucher = "";
          String a[]=request.getParameterValues("voucher");
          for(int i=0;i&lt;a.length;i++){
              voucher+=a[i]+"";
          }
  
          DBConnection dbc=new DBConnection();    
           Connection con=dbc.getNewConnection();
  
           Statement st = null;
           ResultSet rs = null;
           try 
              {
                  st = con.createStatement();
              }
              catch (SQLException e) 
              {
                  e.printStackTrace();
              }
  
              String updatecust = "insert into vouchers(voucher) values('"+voucher+"');";
                      try 
              {
  
                  int i=st.executeUpdate(updatecust);
  
                  if(i&gt;0){
                  out.print(" saved successfully....!!");
                  }
                  else
                     out.print("Sorry..!! Got an exception.");
              }
              catch (SQLException e) 
              {
                  e.printStackTrace();
              }
  
      }
  </code></pre>
  
  <p>This stores check boxes values in single column in single row as below : </p>
  
  <pre><code>mysql&gt; select * from vouchers;
  +--------------------------------------+
  | voucher                              |
  +--------------------------------------+
  | Sales VoucherPurchase VoucherReceipt |
  +--------------------------------------+
  </code></pre>
  
  <p>But i want to store one value in one row and so on. As below(Expected output):</p>
  
  <pre><code>mysql&gt; select * from vouchers;
  +------------------+
  | voucher          |
  +------------------+
  | Sales Voucher    |
  | Purchase Voucher |
  | Receipt          |
  +------------------+
  </code></pre>
  
  <p>Please help me. Thanks in advance!!</p>