getting error while inserting values in database

getting error while inserting values in database

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 Tutorials/Questions & Answers:
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
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
Advertisements
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
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 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
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 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 values in MySQL database table
Inserting values in MySQL database table   ... the facility for inserting the values in MySQL database table. Description...-mysql>java InsertValues Inserting values in Mysql database table
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
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
inserting image into database
inserting image into database  how to insert image into database using struts frame work and spring JDBC
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
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
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
Getting image pixel values
Getting image pixel values  how to get image pixels values on mouse click   import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.io.*; import javax.swing.*; public class
inserting multiple file formats into database
inserting multiple file formats into database  hi i want to insert multiple file format like .pdf.doc.zip into mysql database using jsp
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
Exception while inserting image in oracle using java
Exception while inserting image in oracle using java  import java.sql.*; import java.io.*; class Oracle2 { public static void main(String args[])throws Exception { DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver
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 id in place of name to database
Inserting id in place of name to database  Hello, I have a database department where I have "id" and "name". I am fetching this data to a jsp form in dropdown list displaying "name" there and Now I wanted to insert data from
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
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
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
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
Password need to encrypt while inserting into DB and need to decrypt while responding to forgot password
Password need to encrypt while inserting into DB and need to decrypt while responding to forgot password  Hi, I need the functionality in JSP to encrypt the password while inserting into DB and need decrypt logic while
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
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
inserting multiple file formats into database using html
inserting multiple file formats into database using html   hi the code was working fine,i want to choose the file and then upload to database,by using html.whether it is possible to upload larger file size,please explain
Error While Compiling - Java Beginners
Error While Compiling  Hi All I Am a beginner and i face the following problem while compiling can anyone help me. C:\javatutorial\example> javac HelloWorld.java 'javac' is not recognized as an internal or external
getting an error when set classpath
getting an error when set classpath  Hello Everyone! i have used hssf model for reading excel sheet in my project & i have set classpath... run it, it gives an error "could not find or load main" please help me
Password need to encrypt while inserting into DB and need to decrypt while responding to forgot password
Password need to encrypt while inserting into DB and need to decrypt while responding to forgot password  Hi, i encrypt password and stored in to DB.but i dont know decrypt that password.plz send the code.in your site link
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
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
i am getting multiple values in listbox
i am getting multiple values in listbox   hi sir, i am using msaccess 2007.my query is look like this. select distinct a.name,b.fee from... getting its working fine, but in main query also i am getting multiple name
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
store values of drop down list box in database
store values of drop down list box in database  how to store values of drop down list box in oracle database in jsp?I have information inserting form where i have date of birth as drop down list box
show the database values graphical represantation
show the database values graphical represantation   show the database values graphical represantation and auto refresh for every 30 secand displaying in webpage
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
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
Error while SQL Server connection to Java
Error while SQL Server connection to Java  import java.sql.*; public class OdbcSqlServerConnection { public static void main(String args[]) throws... this code, i am getting an error as OdbcSqlServerConnection.java:29: class,interface
Error while SQL Server connection to Java
Error while SQL Server connection to Java  import java.sql.*; public class OdbcSqlServerConnection { public static void main(String args[]) throws... this code, i am getting an error as OdbcSqlServerConnection.java:29: class,interface
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
Displaying database values in pdf format
Displaying database values in pdf format  Hi All, I am... the form the values are stored in database,the database name is registration... database values should be shown as pdf or excel format. Thanks in advance
edit values of database using jsp
edit values of database using jsp  hi i want a code to edit the row from tye database and display in a page which containd radio buttons and drop down boxes using jsp code
edit values of database using jsp
edit values of database using jsp  hi i want a code to edit the row from tye database and display in a page which containd radio buttons and drop down boxes using jsp code
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... data from database and display it on the textboxes. <%@page language="java
get values from Excel to database
get values from Excel to database   hi i want to insert values from Excel file into database.Whatever field and contents are there in excel file that should go to database which exists. am using SQL Server management studio
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

Ads