Click here to Skip to main content
15,891,718 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
my code is not inserting values in the database.Kindly help!

What I have tried:

ASP.NET
<%@ page import="javax.servlet.http.HttpSession" %>
<%@ page import="java.util.*,java.sql.*" %>
<%@ page import="javax.servlet.http.HttpSession" %>
<%@page import="com.dbutil.CrudOperation"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="css/bootstrap.min.css">
  <link rel="stylesheet" href="css/fullview.css">
  <script src="jquery.js"></script>
  <script src="bootstrap.min.js"></script>
        <title>Job Details</title>
    </head>
    
    <body>
     
       <% Connection con = null;
            ResultSet rs = null;
            PreparedStatement ps = null;
            HttpSession hs = null;
            con = CrudOperation.createConnection();
            hs = request.getSession();
           String value=request.getParameter("idJob");
            String id = (String) hs.getAttribute("userinfo");
            %>
            <div class="container">
                
          
                   
                 <%String strsql = "select name from register where uname=?"; 
                try
		{
			ps=con.prepareStatement(strsql);
			ps.setString(1, id);
			
			
			int rw1=ps.executeUpdate();
				
					
                if(rw1>0) {
                   
                                con.commit();
                    String tryname=rs.getString("name");
                   String strsql1 = "insert into postjob1(applicants) values(?) where id=?"; 
                try
		{
			ps=con.prepareStatement(strsql1);
			ps.setString(1, tryname);
                        ps.setString(2,value);
			
			
			rs=ps.executeQuery();
				
					
                if(rs.next()) {
                    con.commit();
                    response.sendRedirect("confirm.jsp");
                   
                    
                }
                else{
                 response.sendRedirect("Oops.jsp");}
					 
			}
			catch(SQLException se)
				{
					System.out.println(se);
				}

		 
                    
                }
                else{
                response.sendRedirect("Oops1.jsp");}			 
			}
			catch(SQLException se)
				{
					System.out.println(se);
				}

		 

   %>
                %>
           
               
              
            </div>
    </body>
</html>
Posted
Comments
Did you debug and find out the issue? Also wrap your code inside try catch blocks so that you can find out the exceptions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900