Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 29th, 2004, 06:36 AM
Authorized User
 
Join Date: Oct 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default help me..its urgent...

plz let me know how to insert multiple values from the form for the single database column..below i have used query for the single values for the single database coulumn and its working...but how to insert multiple values in a database at a one time.

Statement s=conn.createStatement();

Code = request.getParameter("code");
Description = request.getParameter("Description");//takes values from forms
Dr_Amount=request.getParameter("DrAmount");
Cr_Amount=request.getParameter("CrAmount");
Type = request.getParameter("type");
Pct=request.getParameter("pct");

sql1 = "insert into gl_mast values (" + "'" + Code + "', '" + Description + "' , '" + Dr_Amount + "', '" + Cr_Amount + "', '" + Type + "', '" + Pct + "')" ;
s.executeUpdate(sql1);


sql = conn.prepareStatement("SELECT * FROM gl_mast WHERE gl_code = '" + Code + "'");


 
Old January 7th, 2005, 07:07 AM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi abhit
     i am charith this is my first post at p2p .I am sure that i can help u with this if you provide me some details .Some part of u'r quection is not clear. Tell me your requirmant suerly i will help
by the way i have included the method i use for a single insertion in database.

Normally i use like this

   Connection con;
   PreparedStatement prst=null;
   con = ConnectionManager.getConnection(this);
   String sSql = "INSERT INTO employee(emp_no, emp_fname, emp_mname, emp_sname, emp_address,phoneno)VALUES (?,?,?,?,?,?)";

 prst.setString(1, getEmployeeNo());
 prst.setString(2, getEmpoyeeFName());
 prst.setString(3, getEmpoyeeMName());
 prst.setString(4, getEmpoyeeLName());
 prst.setString(5, getEmpoyeeAddress());
 prst.setInt(6, getEmpoyeeTel().intValue());
 prst.executeUpdate();


bye
Charith
 :)

 
Old January 7th, 2005, 08:06 AM
Authorized User
 
Join Date: Oct 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can u help me in my code..

what would be changes has to be made..



 
Old January 18th, 2005, 12:50 AM
Registered User
 
Join Date: Jan 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

For multiple row entries in a single SQL query, it usually looks something like this:

sql1 = "INSERT INTO gl_mast VALUES('name', 'address', 'zipcode'),
('name2', 'address2', 'zipcode2')
('name3', 'address3', 'zipcode3')";

You could use a loop to build the SQL string, then submit it to the database.

d-







Similar Threads
Thread Thread Starter Forum Replies Last Post
urgent deb_kareng ASP.NET 2.0 Professional 1 August 13th, 2007 07:29 AM
it's urgent deb_kareng ASP.NET 2.0 Professional 3 August 7th, 2007 07:40 AM
urgent help yash_coolbuddy_forindia BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 May 7th, 2007 08:40 AM
urgent???????????? nsr35 Beginning VB 6 1 October 3rd, 2005 10:57 AM
urgent ??????????????? nsr35 Pro VB Databases 0 October 3rd, 2005 04:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.