The Artima Developer Community
Sponsored Link

Java Answers Forum
Inserting data from front end to back end using JSP as front end

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
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
Reply to this message Reply
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>

Topic: anyone can help? Previous Topic   Next Topic Topic: Prime Numbers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use