<%@ page import="java.sql.*" %> " name="description">
Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet problem in inserting data in databases created in ecplise using jsp

Have Programming Question? Ask it here!
 
 
 


suresh
problem in inserting data in databases created in ecplise using jsp
0 Answer(s)      5 months and 29 days ago
Posted in : JSP-Servlet


<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="java.sql.*" %> JS Soft

      <meta name="description" content="free website template" />
      <meta name="keywords" content="enter your keywords here" />
      <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      <meta http-equiv="X-UA-Compatible" content="IE=9" />

     <link rel="stylesheet" type="text/css" href="/js/css/style1.css" />
     <link rel="stylesheet" type="text/css" href="/js/css/menu.css" />
     <link rel="stylesheet" type="text/css" href="/js/css/style.css" />
     <link rel="stylesheet" type="text/css" href="/js/css/layout.css" />

<div id="about">
        <img src="/js/images/cont.png" alt="" />
</div>  
<div class="con">
    <h5>JS-Soft Technologies</h5>
    <div class="con1">
    <p>20-74 NGO Colony</p>
    <p>Main Road</p>
    <p>Nagercoil</p>
    <p>Kanyakumari-2<br><br>
    <p>+919629455197</p>
    <p>+919566262912</p>
</div><!--close con1-->

</div><!--close con-->

<div id="menubar">          
        <ul id="nav">
                   <li><a href="/js/index.jsp">Home</a></li>
                        <li><a href="/js/pages/about.jsp">About</a></li>
                        <li><a class="hsubs" href="#">Services</a>
                            <ul class="subs">
                                <li><a href="/js/pages/application.jsp">Application Services</a></li>
                                <li><a href="/js/pages/web.jsp">Web Services </a></li>
                                <li><a href="/js/pages/testing.jsp">Testin Services</a></li>
                                <li><a href="/js/pages/remote.jsp">Remote Tech Support </a></li>
                                <li><a href="#">SEO</a></li>
                            </ul>
                        </li>
                        <li><a href="/js/pages/career.jsp">Career</a></li>
                        <li><a href="/js/pages/conacts.jsp">Conact Us</a></li>

                  </ul>


        </div><!--close menubar-->  


<div id="cont">
        <h4>Conact Us</h4><br>
        <div>
            <form action="http://localhost:8080/js/pages/conacts.jsp" method="post">
                <table class="contact">
                        <tr><td align="right">*Select Inquiry Type:</td>
                        <td width="30%"><select name="selectinq" class="inputForm">
                                <option value="-1">Select Inquiry Type</option>
                                <option value="Career">Career Seekers</option>
                                <option value="investor">Investor Relations</option>
                                <option value="media">Media</option>
                                <option value="media">Request for Services</option>
                            </select>
                        </td></tr>
                          <TR>
                              <td align="right">First Name</td>
                              <TD width="30%"><INPUT TYPE="text" NAME="fname" size="26%" class="inputForm"></TD>
                          </tr>
                          <TR>
                             <td align="right">Last Name</td>
                             <TD width="30%"><INPUT TYPE="text" NAME="lname" size="26%" class="inputForm"></TD>
                          </tr>
                          <TR>
                             <td align="right">Organization</td>
                             <TD width="30%"><INPUT TYPE="text" NAME="organization" size="26%" class="inputForm"></TD>
                          </tr>
                          <TR>
                            <td align="right">Email</td>
                             <TD width="30%"><INPUT TYPE="text" NAME="email" size="26%" class="inputForm"></TD>
                          </tr>
                          <TR>
                             <td align="right">Phone Number</td>
                             <TD width="30%"><INPUT TYPE="text" NAME="phone" size="26%" class="inputForm"></TD>
                          </tr>
                          <TR>
                             <td align="right">Address</td>
                             <TD width="30%"><INPUT TYPE="text" NAME="address" size="26%" class="inputForm"></TD>
                          </tr>
                          <TR>
                             <td align="right">City</td>
                             <TD width="30%"><INPUT TYPE="text" NAME="city" size="26%" class="inputForm"></TD>
                          </tr>
                          <TR>
                             <td align="right">Country</td>
                             <TD width="30%"><INPUT TYPE="text" NAME="country" size="26%" class="inputForm"></TD>
                          </tr>
                          <TR>
                             <td align="right">Zip</td>
                             <TD width="50%"><INPUT TYPE="text" NAME="zip" size="26%" class="inputForm"></TD>
                          </tr>
                          <TR>
                             <td align="right">Message</td>
                            <td><textarea rows="10" cols="30" name="message" class="inputForm"></textarea></TD>
                          </tr>
                          <TR>
                              <td></td>
                              <TD width="50%"><INPUT TYPE="submit" VALUE="submit" class="inputForm"></TD>
                          </tr>

                </table>

                <%
                       String selectinq = request.getParameter("selectinq");
                       String fname=request.getParameter("fname");
                       String lname=request.getParameter("lname");
                       String organization=request.getParameter("organization");
                       String email=request.getParameter("email");
                       String phone=request.getParameter("phone");
                       String address=request.getParameter("address");
                       String city = request.getParameter("city");
                       String country=request.getParameter("country");
                       String zip = request.getParameter("zip");
                       String message=request.getParameter("message");

/* Create string of connection url within specified format with machine name, port number and database name. Here machine name id localhost and database name is student. */ String connectionURL = "jdbc:mysql://localhost:3306/js";

// declare a connection by using Connection interface 
Connection connection = null;

// declare object of Statement interface that uses for executing sql statements.
 PreparedStatement pstatement = null;

// Load JBBC driver "com.mysql.jdbc.Driver"
 Class.forName("com.mysql.jdbc.Driver").newInstance();

 int updateQuery = 0;

 // check if the text box is empty
 if(selectinq!=null && fname!=null && lname!=null && organization!=null && email!=null && phone!=null && address!=null && city!=null && country!=null && zip!=null && message!=null)
 {

     // check if the text box having only blank spaces
     if(selectinq!=" " && fname!=" " && lname!=" " && organization!=" " && email!=" " && phone!=" " && address!=" " && city!=" " && country!=" " && zip!=" " && message!=" ")
     {

        try {
          /* Create a connection by using getConnection() method that takes 
          parameters of string type connection url, user name and password to connect 
          to database. */
          connection = DriverManager.getConnection(connectionURL, "root", "root");

          // sql query to insert values in the secified table.
          String queryString = "INSERT INTO inquri(selectinq,,fname,lname,organization,email,phone,address,city,country,zip,message) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

         /* createStatement() is used for create statement object that is used for 
           sending sql statements to the specified database. */
          pstatement = connection.prepareStatement(queryString);
          pstatement.setString(1, selectinq);
          pstatement.setString(2, fname);
          pstatement.setString(3, lname);
          pstatement.setString(4, organization);
          pstatement.setString(5, email);
          pstatement.setString(6, phone);
          pstatement.setString(7, address);
          pstatement.setString(8, city);
          pstatement.setString(9, country);
          pstatement.setString(10, zip);
          pstatement.setString(11, message);
          updateQuery = pstatement.executeUpdate();

          if (updateQuery != 0) { %>
            <br>
            <TABLE style="background-color: #E3E4FA;" WIDTH="30%" border="1">
                <tr><th>Data is inserted successfully in database.</th></tr>
            </table>

<% } } catch (Exception ex) { out.println("Unable to connect to batabase.");

        }
        finally {
            // close all the connections.
            pstatement.close();
            connection.close();
        }
     }
   }

%>

            </form>
        </div>

</div>

Everything goes fine but the values are not updated in the table. what to do? plz help?


Advertisement
View Answers

Related Tutorials/Questions & Answers:
problem in inserting data in databases created in ecplise using jsp
problem in inserting data in databases created in ecplise using jsp  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="java.sql.*" %> JS Soft
problem in inserting data in databases created in ecplise using jsp
problem in inserting data in databases created in ecplise using jsp  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="java.sql.*" %> JS Soft
Advertisements
problem in inserting data in databases created in netbeans using jsp..
problem in inserting data in databases created in netbeans using jsp..  i am trying to make a virtual classroom website in jsp using netbeans.i created table inside netbeans through sql editor.and tried to make a login page whose
Problem in inserting clob data in jsp
Problem in inserting clob data in jsp  how to insert any rich text editor data (which have more than 32766 characters) in a clob type column of oracle database with jsp
problem on jsp, inserting data into table(mysql).
problem on jsp, inserting data into table(mysql).  hello friends, I have a problem in jsp.I want to insert data, which is given by user through... is in mysql.I want to use placeholder("?") to insert data into table.Plsssss help
need help....how to connect and disconnect multiple databases(databases created in mysql) using java and my sql
need help....how to connect and disconnect multiple databases(databases created in mysql) using java and my sql  i am working on a project... to know that how to query multiple databases(databases created in my mysql) so
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... of a table,that is none of the data which i tried to enter into database by using
help me in inserting data into db using hibernate
help me in inserting data into db using hibernate  How to insert data into dependent tables through hybernate   Hi Friend, Please visit the following link: http://www.roseindia.net/hibernate/insert-data-database.shtml
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp   data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp with script of data base plz help me
inserting data from radio buttons to database-ERROR - JSP-Servlet
inserting data from radio buttons to database-ERROR  hi, i have... for this problem. thanks and regards nishi kishore  Hi Friend, The whole problem is because of 'option' field in database.It seems that 'option
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...'' at line 1 please provide me the solution of this problem. thanks
inserting data from radio buttons to database - JSP-Servlet
inserting data from radio buttons to database  hi, my problem is as follows: i am creating a feedback form of a college. this feedback form... need a solution of this problem thanks and regards Nishi Kishore  
Inserting Data into mysql - SQL
Inserting Data into mysql  My sincere apologize for this post. I noticed there is no category for php. However am hoping my question will fit... (using php)and inserting the details in a mysql database. Lets take for instance
inserting data into datafields
inserting data into datafields  I was raised with a query.... there is a button, on click on it....... few fields regenerates and the details entered there should be inserted into Database Number of times we click that button
problem in jsp using ms-access
problem in jsp using ms-access  after starting server(tomcat) wen v...)Your DSN will get created. 6) Restart your server and run your jsp code. Here... will get created. 6) Restart your server and run your jsp code. Here is your
Problem in enctype="multipart/form-data" in JSP
Problem in enctype="multipart/form-data" in JSP  im using a page which is in JSP. i have some text boxes and one upload button. i want to load the file itself when i click the submit button. im using enctype="multipart/form-data
inserting value - JSP-Servlet
;Inserting form data into database using JSP and ServletGiven code will illustrate you, how one can get data into database using JSP and ServletExample Code... that will insert the HTML form data into database using JSP and Servlet
hibernate firstExample not inserting data - Hibernate
problem is data is not inserting into DB even though the program is executed... DEFAULT CHARSET=latin1 data is not inserting...hibernate firstExample not inserting data  hello all , i followed
Inserting data in Excel File - Java Beginners
Inserting data in Excel File  Dear Sir, How can we fill the excel with fetched data from the database like Oracle, DB2? Is it possible to create an excel with filled data? Kindly give me the solutions to questions
How to save run time created text-file on a disk using jsp/servlet?
How to save run time created text-file on a disk using jsp/servlet?  I have a JSP page with save button.In that I created the file(e.g a.txt) at run-time,when I click on the save button,it will ask where to save the file
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... for each data cloumn ..at the time of end of the query... PLz see my code and point my
Inserting Mysql CLOB data using Servlet
Inserting Mysql CLOB data using Servlet In this Section, we will insert "clob" data using "servlet". A CLOB is a Character Large Object... portion of the CLOB data. 2.Equallity of 2 CLOBs can  be check by using equals
Problem insert data into database using servlet n javabean - Java Beginners
Problem insert data into database using servlet n javabean  I created a servlet for registration proses I got a problem compiling my servlet... to solve it.. i really new in jsp+servlet+javabean,dont really unnderstand 1)my
Inserting Image(s) - JSP-Servlet
Inserting Image(s)  Hello Guys, Thank you so much for your support so far. I appreciate everything you guys have done for me. Please what I wanted was java servlet or jsp codes that I can use to insert and retrieve image from MS
Inserting Image(s) - JSP-Servlet
Inserting Image(s)  Hello, I need sample code using java servlet...;); File file = new File("C:/apache-tomcat-5.5.23/webapps/jsp/red_rose2.gif...;body><h1>Database Connection Problem.</h1></body></html>
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
how to insert data into database using jsp & retrive
how to insert data into database using jsp & retrive  Hello, I have created 1 html page which contain username, password & submit button. in my oracle10G database already contain table name admin which has name, password
reading data using struts and jsp java
reading data using struts and jsp java  how can i read data entered by user into a textbox (jsp page) into struts action class ex emp id,so... employee related data
get data between date using jsp with msaccess
get data between date using jsp with msaccess  hi, urgently i need program for get data between date using jsp with MsAccess database.plz any one can help me.thanks for anyone replay with regards c.b.chellappa
Databases
Databases  how to add data dynamically into the database table?? i used back end is mysql....   1)form.jsp: <html> <form method...('"+name+"','"+address+"',"+contact+",'"+email+"')"); out.println("Data
inserting text into text file using java application
inserting text into text file using java application  Hi, I want to insert a text or string into a text file using java application
Insert Data in Table Using Stored Procedure
Insert Data in Table Using Stored Procedure        In this example we are inserting data...: To set the values we are using setXXX(). Here XXX is data type Object class name
problem from registering a data in database with servlet - JSP-Servlet
problem from registering a data in database with servlet  Hi Rose, i created a servlet to validates ten user details in the database, if present it should return "You have already registered" but if not it should take all
Accessing Jqxgrid data in Controller layer using JSP
Accessing Jqxgrid data in Controller layer using JSP  I am using Keyboard Navigation jqxgrid. I am able to bind the grid by passing data from controller layer using JAVA. What i actually require is to fetch the data which
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
Exporting data from mysql into csv using jsp
Exporting data from mysql into csv using jsp  Hi friends.... I want to export the data from mysql to csv file using... i am having 30 columns in my database.. Eg- text1,text2,text3,....,upto text30... i want to export this data
Fetch the data using jsp standard action
Fetch the data using jsp standard action  I want the code of fetch the data from the database & show in a jsp page using jsp:usebean in MVC model... that retrieves the data from the database through java bean and display it in jsp page
Inserting Data In Database table using Statement
Inserting Data In Database table using Statement... to insert the data in the database from our java program in the table stored... of the PrintWriter class. We can insert the data in the database only and only
How to get the data from the database using Servlet or JSP program
How to get the data from the database using Servlet or JSP program  .... Actual problem is that i have a simple program in jsp in the sense to get data... the problem   Get data from database using servlet Retrieve data from
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
Retrieving data from data base using jsp combo box
Retrieving data from data base using jsp combo box  Hi guys please help me , i have on GUI page int that Server type(like apache,jboss,weblogic) one combo box is there and another filed is version of the server(like 1.0,2.0) like
Retrieve data from databse using where in JSP
Retrieve data from databse using where in JSP  Hi, can somebody help me? I have a jsp page. in that i want to get data from the database where username is matched. i tried it. but can't get the output. here is the code. please
Delete and edit data in xml file using JSP
Delete and edit data in xml file using JSP   I want to know how to delete and edit data from an XML file by use of JSP. I have XML file having tasks... that i can delete data. For exmple JSP pae will have text box where ill enter
jsp problem
jsp problem  Hi every one plz give me answer for below question ASAP I created one JSP(used pre defined javascript in jsp to get rtf format in browser) which creats RTF Format in browser to enter data. MY question is after i
Problem passing a value from one jsp to another using href
Problem passing a value from one jsp to another using href  first page.jsp <a href="common.jsp?param=<%l.get(k).parentname%>"> common.jsp <%String attr=request.getAttribute("param"); out.print(attr
 

 

 

DMCA.com