Home Answers Viewqa JSP-Servlet getting error while inserting values in database

 
 


megha singhal
getting error while inserting values in database
1 Answer(s)      a year and 2 months ago
Posted in : JSP-Servlet

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...

View Answers









Related Pages:
getting error while inserting values in database
getting error while inserting values in database  AddUser.java...) { out.println("An Error Had occurred while accessing the database... followin error i don't know why "ORA-00947: not enough values". kindly chk
Getting Error - Development process
Getting Error   Hi , i am getting error while executing this code. I just want to store date in to database. Dont mistake me for repeated questions... of query values and destination fields are not the same. my table : Add_Data
Lock while inserting/updating database in multithreaded.
Lock while inserting/updating database in multithreaded.  Hi, I am... inserting/updating to database. I dont know what is the issue but it was never... of each transaction and rollback at the time of error. After each transaction I give
Data is not inserting correctly in mysql database.
Data is not inserting correctly in mysql database.  Hello Sir, below is my code to insert data into database by list iteration through for loop but it is not getting inserted ..it is taking only one value
inserting dropdown values into database table
inserting dropdown values into database table   hi i want to insert dropdown values into a database table by using jsp
error while inserting millions of records - EJB
error while inserting millions of records  Hello, I am using ejb cmp and inserting 1 millions of records but it won't work because trancation time... e.printStackTrace(); } }   The following error is occur
Inserting values in MySQL database table
Inserting values in MySQL database table   ... the facility for inserting the values in MySQL database table. Description... to insert the values in the database. Here we are going to see, how we can
inserting data from radio buttons to database-ERROR - JSP-Servlet
inserting data from radio buttons to database-ERROR  hi, i have already changed the option field of table question. the code which you give me has... it in the code. but still i am getting the error in the update query. please provide
inserting an path of an image in database - JDBC
be saved in the database...I have tried it but getting an error.. plz have a look...inserting an path of an image in database  hello kindly help related... time its full path should be inserted in the database(MS Sql 2000).. I m able
Inserting values into a database table of selected DropDown in jsp.
Inserting values into a database table of selected DropDown in jsp.  http://www.roseindia.net/answers/viewqa/Ajax/15250-DropDown-in-ajax+jsp.html... to insert all selected values in data base correspondent to each like if user
Records are not inserting in to main table while running the mysql stored procedure.
Records are not inserting in to main table while running the mysql stored... that procedure records are not inserted into main table from temp table.But im getting msg... me with this issue. My Code: BEGIN select concat('Inserting into SD
php inserting date into mysql
php inserting date into mysql  php inserting date into mysql   Here is a php code that inserts date into mysql database. In the given code, data is a database table. <?php table $query_manual = "INSERT INTO data
Inserting Image(s) - JSP-Servlet
Inserting Image(s)  Hello, I need sample code using java servlet...;); PreparedStatement pst = con.prepareStatement("insert into uploadfile values(?,?,?)"...;body><h1>Database Connection Problem.</h1></body></html>
Im getting this error while running JPA project
Im getting this error while running JPA project  Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: examplePersistenceUnit] Unable to configure EntityManagerFactory
getting values from database - JSP-Servlet
getting values from database  I tried the following code abc.html aaa.jsp I am not getting exceptions now... JSP code separately.If it will not display database values then try your code
inserting all the values in a html table column
inserting all the values in a html table column  strong text hai everyone, i'm a fresher to servlet i need to know that, how can i insert all the values in a html table column into a database. Thanks in advance
inserting data from radio buttons to database - JSP-Servlet
inserting data from radio buttons to database  hi, i am getting error in my code of feedback form. once i finished selecting all the radio buttons... shows me this error: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have
Inserting a value to an Enum field in Table
as a 'N' but I get some database error that says data truncated. How do I set...Inserting a value to an Enum field in Table  I'm writing a code... database. For example, in the user table I have: username varchar(15) PRIMARY KEY
Database Error - Hibernate
Database Error  Hi, I am working with Struts 1.2---- AJAX-----Hibernate 3.0 --- MySQL 5.0. At the time of inserting/fetching from Database by multiple/single users I am getting the following errors. Lock wait timeout
getting values from dropdown list
getting values from dropdown list  I am having a dropdown list which has hardcoded values ( we need it hardcoded only and will not be populated from the database) My question is when i select a particular value it should be pass
i am inserting an image into database but it is showing relative path not absolute path
i am inserting an image into database but it is showing relative path...("thank u for registration"); out.println("ur values are inserted into database..."); PreparedStatement pst = con.prepareStatement("insert into errortab values
i am inserting an image into database but it is showing relative path not absolute path
i am inserting an image into database but it is showing relative path...("thank u for registration"); out.println("ur values are inserted into database..."); PreparedStatement pst = con.prepareStatement("insert into errortab values
Getting error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver.
Getting error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver.  I am doing project in JSP with database WampServer and glassfish as server .when i done database connection then i get an error
i am inserting an image into database but it is showing relative path not absolute path
i am inserting an image into database but it is showing relative path..."); out.println("ur values are inserted into database"); } catch(Exception e... into errortab values(?,?,?,?,?,?)");</p> pst.setString(1,name); pst.setString
Error with Maven while deploying the war file
Error with Maven while deploying the war file  Hi, I am new..., config and database. in beans i kept dispatch-servlet.xml and in database i kept... any link on the index page it shows 500 error.. My pOM.xml is <project
urgent help for inserting database in a project
urgent help for inserting database in a project   I need some urgent... and then the result at the end.I need to add simple database connectivity...(this).start(); } public void run() { while(start_test
urgent help for inserting database in a project
urgent help for inserting database in a project   I need some urgent... and then the result at the end.I need to add simple database connectivity...(this).start(); } public void run() { while(start_test
problem in setting the values from database
the values from database. here is the code: private JTextField getJTextField1...(""); text.requestFocus(true); System.out.println("error while...!"); System.out.println("error while validating"+ex
inserting image in mysql database using browse button in servlets
inserting image in mysql database using browse button in servlets  Hi,I want to insert a image in mysql database using browse button. and, i want...; while (totalBytesRead < formDataLength) { byteRead = in.read(dataBytes
getting classnotfound exception while running login application
getting classnotfound exception while running login application  hi, I am getting Error creating bean with name 'urlMapping' defined... to bean 'loginController' while setting bean property 'urlMap' with key
Applet to database error - Applet
Applet to database error  Hi... I had an application where i need to connect to the database for the values to display in the applet.... Following... is displaying null values as the result... public class circuit extends
Oracle Database error - JDBC
Oracle Database error   String query11 = "SELECT product_code... = stmt.executeQuery(query11); while(rs11.next()){ product_code[j...); } rs11.close(); This is my code. I want to save Result set values in array
error while compiling - Java Beginners
error while compiling  i am facing problem with compiling and running a simple java program, can any one help me, the error i am getting is javac is not recognised as internal or external command  Check if you JAVA_HOME
large resultset values - SQL
large resultset values  i have one query which will bring more than one lakh records from database(total records are abt 3 crores). While getting the details i'm getting error like
Inserting data on a database in servlet - JSP-Servlet
Inserting data on a database in servlet  Hi I am following... to a databse by a servlet.I used the example in "Inserting Data In Database table...:8080/DataInsertion/DataInsertion) in the browser, I just saw my designed database in the form
duplicate records inserting
duplicate records inserting  in the application i have provided the text filed on entering and submit the record is getting inserted. my question is i want to avoid duplicate values getting inserted. ex. i am inserting name
inserting picture in ms access
inserting picture in ms access  hi i am sanatan, how to insert... into user(name,address,image) values(?,?,?)"); pre.setString(1...()); pre.executeUpdate(); out.println("Inserting Successfully
error
error  while iam compiling iam getting expected error
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  ... ,update,delete database values from jtable only so i added three buttons add... of particular row is not getting added into the database whereas all other records
inserting into mysql database with uid to be primary key and autoincrement
; Here is the code of inserting values from jsp form to database...inserting into mysql database with uid to be primary key and autoincrement  hello, i am new to jsp and facing problem in creating a database entry
inserting value - JSP-Servlet
the database mySQl with the help of servlet. Inserting form data   Inserting form data into database using JSP and ServletGiven code will illustrate you...inserting value  sir i want to create a web application when we use
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  ... ,update,delete database values from jtable only so i added three buttons add,update... row is not getting added into the database whereas all other records are getting
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  ... ,update,delete database values from jtable only so i added three buttons add,update... row is not getting added into the database whereas all other records are getting
database
database  How can i get combo box values from database?? or how can i get values in the drop down menu of the html which is similar to dat of combo box in java - from database? you had given me the answer <%@page
getting dropdown values using apache commons in servlet
getting dropdown values using apache commons in servlet  i want to get dropdown values in my program in order to merge the string to my file path so...); } i tried to debug and i am getting the wright file path but while proceeding
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table wth edit...); while(rs.next()) { out.println("<tr>"); out.println("<td>
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table as if i am... = con.createStatement(); rs = st1.executeQuery(query); while(rs.next
inserting image into database
inserting image into database  how to insert image into database using struts frame work and spring JDBC
Getting an error :(
Getting an error :(  I implemented the same code as above.. But getting this error in console... Console Oct 5, 2012 10:18:14 AM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server
Getting Textbox data from database
Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown... an internal error () that prevented it from fulfilling this request. exception

Ask Questions?

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.