Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Have Programming Question? Ask it here!
 
 
 


megha singhal
getting error while inserting values in database
1 Answer(s)      2 years and 4 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...


Advertisement
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
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
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
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... to insert the values in the database. Here we are going to see, how we can
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
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
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
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 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 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 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
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 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 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
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
getting error in your login form code
getting error in your login form code  i tried your code for login form but i am getting an error.the error is undefined index userid and password.the code is $fuser=$POST["userid"];. how to solve this problem please help me
data type used to store name.(getting an error)
data type used to store name.(getting an error)    Statement stm=con.createStatement(); String query="select * from employee where ename... getting an error like dis: "ename cannot be resolved to a variable" whats
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
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
Getting connect error in Jmeter - Development process
Getting connect error in Jmeter  Hi, Am trying to run a simple application in Jakarta Jmeter using HTTP request sampler. I am getting the below error. Please help me in viewing the results. Pl specify if there is any possible
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
i got an error while compile this program manually.
i got an error while compile this program manually.  import javax.servlet.http.*; import org.apache.struts.action.*; public class ActionOne{ public...,struts jar files and i got an error in saveErrors() error Heading cannot find
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
Advertisements
 

 

 

DMCA.com