/    Sign up×
Community /Pin to ProfileBookmark

addBatch() prob……….

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.getParameter(“gl_code1[n]”)));
pstmt.setString(2,request.getParameter(“gl_descr1[n]”));
pstmt.setFloat(3,Float.parseFloat(request.getParameter(“db_amt1[n]”)));
pstmt.setFloat(4,Float.parseFloat(request.getParameter(“cr_amt1[n]”)));
pstmt.setString(5,request.getParameter(“gl_type1[n]”));
pstmt.setFloat(6,Float.parseFloat(request.getParameter(“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.service(JspServletWrapper.java:372 )
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.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(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324 )
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.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″

to post a comment
Java

1 Comments(s)

Copy linkTweet thisAlerts:
@ray326Dec 30.2004 — IMHO your main problem is that you're doing something in a JSP that should be done in a servlet.
×

Success!

Help @abhit_kumar spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...