insert data to mysql in wamp using jsp and tomcat,pls reply
Posted by: thanhtunaung (203.81.72.---)
Date: January 26, 2009 03:52PM

hi
i have a problem with using together jsp and wamp.i use tomcat and wamp server.i put mysql connector 5.0.1 in tomcat web-inf.i create airline database and login table in wamp.my jsp program put tomcat root.
register.jsp run inserting data from my form no error are outputted although the records are not being inserted login table in airline database in wamp.my code is

register.jsp
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[www.w3.org];
<html xmlns="[www.w3.org];
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
</style>
</head>

<body>


<h1>Register Here:</h1>
<form action="insert.jsp" method="post">
<p><strong>Bc Number:</strong>
<input type="text" name="username" />
</p>

<p><strong>Password:&nbsp; &nbsp; </strong>
<input type="password" name="password" />
</p>
<input type="submit" name="submit" value="Submit" />
<p></p>
</form>
</body>
</html>

insert.jsp
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[www.w3.org];
<html xmlns="[www.w3.org];
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head><%@ page import="java.sql.*" %>
<body>
<p align="left">
<% String username=request.getParameter("username"winking smiley;
String password=request.getParameter("password"winking smiley;
%>
<% int i=-1;
try{
Class.forName("com.mysql.jdbc.Driver"winking smiley;
Connection con =DriverManager.getConnection("jdbc:mysql://localhost:3306/airline"winking smiley;
Statement stmt =con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sqlStatement= "INSERT INTO login(username,password) VALUES('"+username+"','"+password+"')";

i=stmt.executeUpdate(sqlStatement);
}catch(SQLException e){
e.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
if(i==1)
response.sendRedirect("Login.jsp"winking smiley;
else
response.sendRedirect("insert.jsp"winking smiley;
%>

</body>
</html>

Options: ReplyQuote
Re: insert data to mysql in wamp using jsp and tomcat,pls reply
Posted by: anukini05 (---.186.3.245.dvois.com)
Date: June 27, 2015 06:26AM

How to connect the jdbc driver to the database ?

Options: ReplyQuote
Re: insert data to mysql in wamp using jsp and tomcat,pls reply
Posted by: Otomatic (Moderator)
Date: June 27, 2015 09:15AM

Cette question est Hors Sujet
Ce site est destiné aux personnes ayant des problèmes de fonctionnement de WAMPServer et non pas un site COMMENT FAIRE POUR toute chose relative au Web

This question is not On Topic
This site is for people having issues getting WAMPServer running and not a general HOW DO I site for everything web related.

Discussion closed.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote


Sorry, you can't reply to this topic. It has been closed.