
AddUser.java
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.lang.String;
import java.sql.Connection;
import javax.servlet.RequestDispatcher;
import java.sql.Statement;
import java.sql.ResultSet;
import javax.naming.*;
import javax.naming.directory.*;
import oracle.jdbc.pool.OracleDataSource;
public class AddUser extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String LASTNAME = request.getParameter("LASTNAME");
String FIRSTNAME = request.getParameter("FIRSTNAME");
String ADDRESS = request.getParameter("ADDRESS");
String CITY = request.getParameter("CITY");
Connection con = null;
Statement st1 = null;
ResultSet rs = null;
try {
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
OracleDataSource ds = (OracleDataSource) envContext.lookup("jdbc/abc");
if (envContext == null)throw new Exception("Error: No Context");
if (ds == null) throw new Exception("Error: No DataSource");
if (ds != null)
con = ds.getConnection();
st1 = con.createStatement();
ArrayList al=null;
ArrayList userList =new ArrayList();
String query = "insert into LTCINFO.PERSONS values ('"+LASTNAME+"','"+FIRSTNAME+"','"+ADDRESS+"','"+CITY+"')";
int i = st1.executeUpdate(query);
if(i>0)
{
response.sendRedirect("SRord");
}
rs.close();
st1.close();
con.close();
} catch (SQLException se) {
out.println("An Error Had occurred while accessing the database");
out.println("<HR>");
out.println(se.getMessage());
}
catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (rs != null)
rs.close();
if (st1 != null)
st1.close();
if (con != null)
con.close();
} catch (Exception e) {
out.println(e);
}
}
}
} addUser.jsp
<html>
<head>
</head>
<body>
<form name="userform" method="post" action="AddUser">
<br><br><br>
<table align="center" width="300px" style="background-color:#EDF6EA;border:1px solid #000000;">
<tr><td colspan=2 style="font-weight:bold;" align="center">Add User</td></tr>
<tr><td colspan=2 align="center" height="10px"></td></tr>
<tr>
<td style="font-weight:bold;">LASTNAME</td>
<td><input type="text" name="LASTNAME" value=""></td>
</tr>
<tr>
<td style="font-weight:bold;">FIRSTNAME</td>
<td><input type="text" name="FIRSTNAME" value=""></td>
</tr>
<tr>
<td style="font-weight:bold;">ADDRESS</td>
<td><input type="text" name="ADDRESS" rows=5 cols=25></td>
</tr>
<tr>
<td style="font-weight:bold;">CITY</td>
<td><input type="text" name="CITY" value=""></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="Save" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
</tr>
<tr><td colspan=2 align="center" height="10px"></td></tr>
</table>
</form>
</body>
</html>
for the above i m facing followin error i don't know why "ORA-00947: not enough values". kindly chk this...

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.