Update Oracle Database From JSP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajay13785
    New Member
    • Oct 2013
    • 10

    Update Oracle Database From JSP

    I want to update my oracle database column from a text box ,so whenever I input some text value in the text
    box and click UPDATE button the database field should be updated . I have a drop down menu also ,so when ever I select the drop down and enter in the text box that field should be updated.
    I have written the code but its not working . Please help me out its Urgent.

    My jsp code
    Code:
    <%@ page  language="java"  import="java.sql.*" %>
    <%@ page import = "java.io.*"%>
    
       <% 
                
          String id = request.getParameter("ID");
         int num=Integer.parseInt(id);
        
           String url= request.getParameter("URL");
         
         
         %>
    
        <%
    
        try{
    	
    	Connection conn = null;
    		 
    	Class.forName("oracle.jdbc.OracleDriver"); 
    		
    	conn = DriverManager.getConnection("jdbc:oracle:thin:SCOTT/tiger@computer_1:1521:orcl");
    	 
    	Statement st= null;
    	
    	st=conn.createStatement();
    	st.executeUpdate("UPDATE TEST_LINKS SET URL= '"+url+"'WHERE ID= '"+num+"' ");
    	 	 
          }
        catch(Exception e){
    	System.out.println(e);
    	    }
    	  %>
    Last edited by Rabbit; Nov 3 '13, 05:40 AM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Do not write database updating code in JSPs. JSPs should be used for presentation only. Put all that database logic on a nomal Java class and test that it works without involving JSPs, then let your JSP submit to a servlet which uses that Java class.

    Comment

    Working...