geethavasan
Posts: 12
Nickname: geetha
Registered: Dec, 2002
|
|
Inserting data from front end to back end using JSP as front end
|
Posted: Feb 24, 2003 3:26 AM
|
|
|
Advertisement
|
hi could anyone of you plz help me? I am trying to insert data from my front end. i,e. JSP to back end - ACCESS database...
but i find that the data is not inserted when i execute it plz help me. Thanks in advance
My code is ------------------------------------------------------------
<%@ page language="java" import="java.sql.*" %>
<html> <head> <title> Insertion </title> </head>
<body> <hr color ="red" > <h3><center><b> Welcoime </b> </center> </h3> <hr color = "red" >
<% String driver = "sun.Jdbc.Odbc.JdbcOdbcDriver" ; String url = "jdbc:odbc:std";
Connection conn = null; Statement stmt = null;
try { Class.forName(driver); conn = DriverManager.getConnection(url); stmt = conn.createStatement();
String regno = request.getParameter("regno"); String name = request.getParameter("name"); String uname = request.getParameter("uname"); String password = request.getParameter("password"); String repassword = request.getParameter("repassword");
// Check for the Q string String sql = " " + " INSERT INTO Register VALUES ('" + regno + "' , '" + name + "' , '" + uname + "' , '" + password + "' , '"+repassword + "')"; stmt.executeUpdate(sql); stmt.close(); stmt = null; } catch(Exception e) { System.out.println("Exception in Connecting to database"+e.getMessage()); e.printStackTrace(); } finally { if(conn != null) { conn.close(); } } %>
</body> </html>
|
|