need complete jsp code for transactions using mysql

need complete jsp code for transactions using mysql

View Answers

November 25, 2009 at 2:35 PM

Hi Friend,

We have create two database tables user(id,username,password) and bank(id,username,ano,balance).

Try the following code:

1)login.jsp:

<html>
<head>
</head>
<body>
<form name="loginform" method="post" action="auth.jsp">
<br><br>
<table align="center"><tr><td><h2>Login Authentication</h2></td></tr></table>
<table width="300px" align="center" style="border:1px solid #000000;background-color:#efefef;">
<tr><td colspan=2></td></tr>
<tr><td colspan=2>&nbsp;</td></tr>
<tr>
<td><b>Login Name</b></td>
<td><input type="text" name="username" value=""></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input type="password" name="password" value=""></td>
</tr>

<tr>
<td></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
<tr><td colspan=2>&nbsp;</td></tr>
</table>
</form>
</body>
</html>

2)auth.jsp:

<%@ page language="Java" import="java.sql.*" %>
<%
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "register";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
if(request.getParameter("username")!=null && request.getParameter("username")!="" && request.getParameter("password")!=null && request.getParameter("password")!="")
{
String username = request.getParameter("username");
String userpass = request.getParameter("password");;
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select * from user where username='"+username+"' and password='"+userpass+"'");
int count=0;
if(rs.next()){ %>
<a href="webpage1.jsp">Cash Transaction</a>
<%
}
else {
response.sendRedirect("login.jsp");
}

}
}
catch(Exception e){}
%>

November 25, 2009 at 2:36 PM

continue....

3)webpage1.jsp:

<html>
<form method="post" action="webpage2.jsp">
<table>
<tr><td>Account No</td><td><input type="text" name="no"></td></tr>
<tr><td>Transfer Amount</td><td><input type="text" name="amount"></td></tr>
<tr><td>To Account No</td><td><input type="text" name="to"></td></tr>
<tr><td><input type="submit" value="submit"></td></tr>
</table>

4) webpage2.jsp:

<%@page import="java.sql.*"%>
<%
int acc1=Integer.parseInt(request.getParameter("no"));
int bal=Integer.parseInt(request.getParameter("amount"));
int acc2=Integer.parseInt(request.getParameter("to"));

try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register";, "root", "root");
Statement st = con.createStatement();

ResultSet rs = st.executeQuery( "select balance from bank where ano='"+acc1+"'");

int balance1=0;
while (rs.next()) {
balance1=rs.getInt("balance");
}
ResultSet rs1 = st.executeQuery( "select balance from bank where ano='"+acc2+"'");

int balance2=0;
while (rs1.next()) {
balance2=rs1.getInt("balance");
}

int bal1=balance1-bal;
int bal2=balance2+bal;

st.addBatch("update bank set balance="+bal1+" where ano='"+acc1+"'");
st.addBatch("update bank set balance="+bal2+" where ano='"+acc2+"'");
st.executeBatch();
out.println("Transaction has been successfully done.");
}
catch(Exception e){}
%>

Thanks









Related Tutorials/Questions & Answers:
need complete jsp code for transactions using mysql - WebSevices
need complete jsp code for transactions using mysql  iam doing online banking project.i want the code to transfer funds from one account to another... to lasya or lasya to prathika. I need complete jsp code for transactions using
urgent need for jsp code with mysql query for uploading and downloading file - JSP-Servlet
urgent need for jsp code with mysql query for uploading and downloading file  can anyone tell me how to upload and download a doc file using jsp with mysql as the back end... and kindly help me to create the table too
Advertisements
need JSP Code.
need JSP Code.  **Hi I need JSP code for selling Products which are in Database. Please can any one help for this.URGENT... Thank You..! Abhijeet
Need a JSP CODE
Need a JSP CODE  *Hi I need JSP source code for selling products which are in database.. please can any one help me ..URGENT* Thank You
Need a jsp code
Need a jsp code  I need a jsp code in which when i select a value.....please help me for this.   The given code retrieves the employee name... =""; if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { var showdata
Insert a row in 'Mysql' table using JSP Code
Insert a row in 'Mysql' table using JSP Code In this section, we will discuss about how to insert data in Mysql database using JSP code. Query... between your Tomcat server & Mysql database Table. Code to insert row in Mysql
tree using jsp code
tree using jsp code  i want to draw a tree structure of a family hierarchy using jsp code
jsp using include & with mysql
jsp using include & with mysql  Sir, I am creating a login application using jsp & Mysql. The Codes are--- Html File...... <...; Jsp file....... <%@ page import="java.sql.*" %> <% String
jQuery auto complete through database using JSP
jQuery auto complete through database using JSP In this tutorial, we will implement auto complete through database using JSP. In this example a text box... it , by completing text using JSP. JSP page take the uncompleted text  form text
login page with mysql using jsp
login page with mysql using jsp  pls i need a sample of login page to check username and password in mysql database. thanks
i need the source code to generate id in jsp
i need the source code to generate id in jsp  hai,i need the source code for generate id...which is i need to generate the new id from the maximum... of generate ids each should have some range...plz give the source code in jsp with ms
database connectivity using jsp code
database connectivity using jsp code  i have two tables employee...),'bbbb','bbbb'); so this syntax is possible to use in jsp code based on employee id ename and designation are displayed how it is possible in jsp employee
Image upload in mysql database using jsp servlet
Image upload in mysql database using jsp servlet  Hello, I need code to insert image in mysql database, I have seen the code which is already in your... located inside the application, but i need to upload in mysql and also for inserting
jQuery auto complete through database using JSP shows error
jQuery auto complete through database using JSP shows error  The tutorial on jQuery titled "jQuery auto complete through database using JSP" shows error on browser when I try to select the one in the dropdown. Please help
online shopping code using jsp
online shopping code using jsp  plz send me the code of online shopping using jsp or jdbc or servlets plz plz help me
need to open a file that is in server using jsp
need to open a file that is in server using jsp   im doing a web application where i can upload and download pdf files from server.in this i created... open link it should be opened in jsp.downlaoding part was done by me. wt i need
Need Help in creating online quiz application using JSP - JSP-Servlet
Need Help in creating online quiz application using JSP  Hi, i am creating online Quiz application using JSP and MySQl ,Apache 6 in Netbeans IDE. i... ---------------------------------------------------------------------------------------------------- JSP Page
how to fetch image from mysql using jsp
how to fetch image from mysql using jsp  how to fetch image from mysql using jsp
need help....how to connect and disconnect multiple databases(databases created in mysql) using java and my sql
in mysql) using java and my sql  i am working on a project on deadlock in distributed transactions , and in that i am using my sql in java i need... such program if u can provide me...plz plz...help i need the idea/code/implementation
upload csv to mysql db using jsp upload
upload csv to mysql db using jsp upload  Hello all, Please give me the code to uplad .csv from jsp page and insert values into MySQl db. I have a table with 8 cloumns.(MDN--varchar(30),Otafdate date,crt varchar(30),dmdn
jsp fie execution in tomcat and using mysql - JDBC
jsp fie execution in tomcat and using mysql  I created 2 jsp files... are the MySql username and password.The code we have provided you checks whether... and password to enter into the Mysql database account.the other named
Insert Blob(Image) in Mysql table using JSP
Insert Blob(Image) in Mysql table using JSP In this Section, we will insert blob data(image) in Mysql database table using JSP code. A Blob stores a binary..._TO_REPLACE_8 See also :   Display Blob(Image) in Mysql table using
how to display jsp page containing mysql query in particular division using ajax ?my code is below bt i cundt get it properly
how to display jsp page containing mysql query in particular division using ajax ?my code is below bt i cundt get it properly   index.html <... will display here</div> </body> </html> print("code sample
No complete code for AbstractWizardFormCOntroller Example
No complete code for AbstractWizardFormCOntroller Example  No complete codes
code for password strength using jsp-servlet
code for password strength using jsp-servlet  hi.............. plz help me to give code for password strength using jsp-servlet for implementation in my project as soon as possible because i want to show this functionality in my
Error in MySQL Procedure Using JAVA Code
Error in MySQL Procedure Using JAVA Code  The following Java code (using Connector/J to create a stored procedure on MySQL 5.0) does not execute successfully. Identify the cause and available solutions. statement.execute
populating text box using jsp code
populating text box using jsp code  Sir, How to populate related values in a text box after selecting value from drop down list using JSP and mysql.... Please give an example using jsp code only.   dependentDropdown.jsp
login page using jsp servlrt with mysql database?
login page using jsp servlrt with mysql database?  Description: example:total users are 3.each use have username and password save in mysql database table login. After successfully login user1 see only index page,if user2 login
need a sample project using java technologies like jsp, servlets, struts
need a sample project using java technologies like jsp, servlets, struts  Hi everybody! I have learnt core java,jdbc,jsp,servlets & struts... other project with detailed explanation using the above technologies by which i
code to send sms alerts using jsp online
code to send sms alerts using jsp online  I am new to mobile aplication development. pls send me the code for sms alerts after clicking the button
Exporting data from mysql into csv using jsp
Exporting data from mysql into csv using jsp  Hi friends.... I want to export the data from mysql to csv file using... i am having 30 columns in my... want csv file with 10 rows.. i want to do in jsp... pls help me soon..its very
access image from ajax store in mysql using jsp
access image from ajax store in mysql using jsp  access image from ajax store in mysql using jsp (code to access image captured by camera and store in mysql
Using javabeans to connect mySQL database on a jsp page - JSP-Interview Questions
Using javabeans to connect mySQL database on a jsp page  Hi, Am doing......; Connecting a JSP page to MYSQL Database using JavaBean File Name: beancode.java   Connecting a JSP page to MYSQL Database using JavaBeanFile Name
code for jsp to db connection using jdbc
code for jsp to db connection using jdbc  please send me the code   Hi Friend, Try the following code:ADS_TO_REPLACE_1 1)form.html: <html> <form method="post" action="http://localhost:8080/examples/jsp
Display Blob(Image) from Mysql table using JSP
Display Blob(Image) from Mysql table using JSP In this section, we will display blob data(image) from Mysql database table using JSP code. A Blob stores... Also : Insert Blob(Image) in Mysql table using JSP Download Source CodeADS
Upload Exce Data into MySql Using Jsp and Servlet - JSP-Servlet
Upload Exce Data into MySql Using Jsp and Servlet  now i am doing... into Mysql Database table so please give the coding to me, it's very urgent for me... the following link: http://www.roseindia.net/jsp/upload-insert-csv.shtml Hope
need of code
need of code  howto convert greyscale image to binary image in java
get info from mysql using jsp and servlet
get info from mysql using jsp and servlet  HELLO! I wanna create a jsp page which able to let me get its name, phone and other info by asking the user to key in their email address from mysql database by using servlet and jsp too
Read Excel data using JSP and update MySQL databse
Read Excel data using JSP and update MySQL databse  HOw to read excel data using JSP and update MySQl database
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
insert name city and upload image in database using mysql and jsp
insert name city and upload image in database using mysql and jsp   insert name city and upload image in database using mysql and jsp
Using MYSQL Database with JSP & Servlets.
Using MYSQL Database with JSP & Servlets.  ... acceres the MYSQL database. Here I am using MYSQL & tomcat server... the installation is complete. MYSQL   
retrieve related data from database using jsp and mysql
retrieve related data from database using jsp and mysql  Hi sir, please give some example of jsp code for retrieving mysql database values in multiple dropdown list. if we change a value in a dropdown its related value must
retrive the employee details with image from mysql database using jsp servlet
retrive the employee details with image from mysql database using jsp servlet  im doing the web project to retrive the employee profile which i stored in the database using jsp servlet then want to show the result in the next jsp
I need jsp code for how to write text field value into property file.
I need jsp code for how to write text field value into property file.  Hi , I need to set the text field value into property file using jsp code. Example : Username : Valar , I have entered the value "Valar" in the text field
JSP-Mysql - JSP-Servlet
JSP-Mysql  Hello friends, Anyone send me the way how to store image in mysql database from a jsp page.  Hi friend, Code to insert image in mysql Using Jsp : For more information on JSP
How to connect to MySQL in JSP?
How to connect to MySQL in JSP?  How to connect to MySQL in JSP? Share the code example with complete project source code. Thanks   Hi, You can use the Java JDBC code to connect to MySQL database in JSP page. Check
can any one give the frogort password code using jsp,
can any one give the frogort password code using jsp,  plz give the code for frogot password

Ads