| | |
java.lang.NoClassDefFoundError: java/lang/StringBuilder
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: May 2007
Posts: 4
Reputation:
Solved Threads: 0
I am doing servlet program. It is working when I run it as a GUI appliction.
But when I run it as a web application it arises java.lang.NoClassDefFoundError: java/lang/StringBuilder
at SDBApp.service(SDBApp.java:14)please help me.
Here is my code.
SDBApp.java
I marked red letters where I am getting problems.
But It is working in GUI application.
This is url : http://localhost:7001/dbapp/formone.html
Here is the html form formone.html which we sends request to.
And this is the web.xml
Here is the problem where it arises
String vsql = "insert into employee values("+vno+",'"+vname+"')";
In the DataBase
we have employee table.with two columns no which is number and name which is varchar2(14)
If we use selet * from employee in above program It is working in web application.
please help me.
But when I run it as a web application it arises java.lang.NoClassDefFoundError: java/lang/StringBuilder
at SDBApp.service(SDBApp.java:14)please help me.
Here is my code.
SDBApp.java
/*servlet which takes care of inserting rows in Data Base*/
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class SDBApp extends HttpServlet
{
private Connection con;
private Statement stmt;
public void service(HttpServletRequest sreq,HttpServletResponse sresp){
DBConnection dbcon = new DBConnection(con);
con = dbcon.dbConnection();
String vno =sreq.getParameter("no");
String vname = sreq.getParameter("name");
String vsql = "insert into employee values("+vno+",'"+vname+"')";
try{
stmt = con.createStatement();
stmt.executeUpdate(vsql);
}catch(Exception e){}
}
};But It is working in GUI application.
This is url : http://localhost:7001/dbapp/formone.html
Here is the html form formone.html which we sends request to.
Java Syntax (Toggle Plain Text)
<HTML> <BODY> <form method="get" action="sdbapp"> Enter No : <input type="text" name="no"><br> Enter Name: <input type="text" name="name"><br> <input type="submit" value="send"> </form> </BODY> </HTML>
Java Syntax (Toggle Plain Text)
<web-app> <servlet> <servlet-name>sdbapp</servlet-name> <servlet-class>SDBApp</servlet-class> </servlet> <servlet-mapping> <servlet-name>sdbapp</servlet-name> <url-pattern>/sdbapp</url-pattern> </servlet-mapping> </web-app>
String vsql = "insert into employee values("+vno+",'"+vname+"')";
In the DataBase
we have employee table.with two columns no which is number and name which is varchar2(14)
If we use selet * from employee in above program It is working in web application.
please help me.
You forgot to put single quotes before and after double quotes on first inserted value vno
That should sort your problem
String vsql = "insert into employee values('"+vno+"','"+vname+"')";
That should sort your problem
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: May 2007
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
You forgot to put single quotes before and after double quotes on first inserted value vno
String vsql = "insert into employee values('"+vno+"','"+vname+"')";
That should sort your problem
The same problem I am getting.
Above I mentioned that I ran the same program Using GUI application there it is running.
And also the "vno" field is "number" in Data Base.
Here is the table in DB
employee(no number(3),name varchar2(15));
PLEASE HELP ME TO SOLVE THIS PROBLEM.
![]() |
Similar Threads
- Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error (Java)
- java.lang.NoSuchMethodError (Java)
- java.lang.NoClassDefFoundError: JBuilder (Java)
- exception in thread "main" java.lang.NoClassDefFoundError (Java)
- Question about java.lang.SecurityException (Java)
- Following tutorials and getting java.lang.NoClassDefFoundError (Java)
Other Threads in the Java Forum
- Previous Thread: help with run length encoding
- Next Thread: secret mission
Views: 7274 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for Java
3d @param affinetransform android api apple applet application arc arguments array arrays automation binary bluetooth byte c# chat class classes click client code color compare component corrupted database detection draw eclipse error event exception file fractal game givemetehcodez graphics gui guitesting helpwithhomework html ide image input integer j2me java java.xls javaprojects jmf jni jpanel julia keytool keyword linux list loop map method methods mobile netbeans newbie number object oracle pong print problem producer program programming project projectideas read recursion reflection rim scanner screen server set size sms socket sort sql string swing terminal test threads time transfer tree web windows






