Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 29th, 2004, 04:32 AM
abhit_kumar abhit_kumar is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 22 abhit_kumar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 3 sec
Reputation Power: 0
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 + "'");

Reply With Quote
  #2  
Old December 29th, 2004, 09:09 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
I'm a little unclear.
Which part is giving you the error, and what is the error?

Is the data correctly inserting into the database?

Reply With Quote
  #3  
Old December 30th, 2004, 12:53 AM
abhit_kumar abhit_kumar is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 22 abhit_kumar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 3 sec
Reputation Power: 0
Prob...in addBatch() prepared Satetemt

hey i have used addBatch metho..but its coming error of null exception
pstmt = conn.prepareStatement("INSERT INTO gl_mast VALUES (?, ?, ?, ?, ?, ?)");
for (int n = 0; n < 100; n++) {
pstmt.setInt(1,Integer.parseInt(request.getParamet er("gl_code1[n]")));
pstmt.setString(2,request.getParameter("gl_descr1[n]"));
pstmt.setFloat(3,Float.parseFloat(request.getParam eter("db_amt1[n]")));
pstmt.setFloat(4,Float.parseFloat(request.getParam eter("cr_amt1[n]")));
pstmt.setString(5,request.getParameter("gl_type1[n]"));
pstmt.setFloat(6,Float.parseFloat(request.getParam eter("gl_pct1[n]")));

pstmt.addBatch();
}
pstmt.executeBatch();

error

HTTP Status 500 -

------------------------------------------------------------------------------- -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: null
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


root cause

java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Integer.java:436)
java.lang.Integer.parseInt(Integer.java:518)
org.apache.jsp.MENU.gl_005fmaster.gl_005fsave_jsp. _jspService(gl_005fsave_jsp.j ava:82)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs.


------------------------------------------------------------------------------- -

Apache Tomcat/5.0.30


it retrieves values from below text

<input type="text" name="code" size="5" maxlength="5">
<input type="text" name="Description" size="55">
<input type="text" name="DrAmount" size="12" >
<input type="text" name="CrAmount" size="12"">
<input type="text" name="type" size="12"">

and this rows is increased for entering data..and its values like that..
Each time when adding a new row, the names are "incremented" following the pattern

1st row

name="code"
name="Description"
name="DrAmount"
name="DrAmount"
name="CrAmount"
name="type"

2nd row - new created

name="code_1"
name="Description_1"
name="DrAmount_1"
name="DrAmount_1"
name="CrAmount_1"
name="type_1"

3rd row - new created

name="code_1"
name="Description_1"
name="DrAmount_1"
name="DrAmount_1"
name="CrAmount_1"
name="type_1"

Reply With Quote
  #4  
Old December 30th, 2004, 04:11 AM
Joru Joru is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: kop
Posts: 2 Joru User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Hi

I want to know from u that how to display the Query on this site

Reply With Quote
  #5  
Old December 30th, 2004, 04:14 AM
Joru Joru is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: kop
Posts: 2 Joru User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Hi

I want to know that how to display the Query(problems) on this site

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > help me..its urgent...


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap