Home Answers Viewqa WebSevices need complete jsp code for transactions using mysql

 
 


harshitha
need complete jsp code for transactions using mysql
2 Answer(s)      3 years and 6 months ago
Posted in : WebSevices

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 Pages:
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
Chapter 11. Transactions
(BMT) demarcation, the enterprise bean code demarcates transactions using...;TransactionsIdentify correct and incorrect statements or examples about EJB transactions... transactions. The Enterprise JavaBeans architecture allows an application
Chapter 5. EJB transactions
described above. However, complete isolation of transactions, although offering... transactions Build EJBs which satisfy transactional requirements EJB transactions are a set of concepts and a set
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
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
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
need code for file browser
need code for file browser  hi, i need to write a code to browse the file in my computer using Jsp or java.. what is the code for file browser?   JSP Code for browsing: 1)page.jsp: <%@ page language="java" %>
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
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
auto complete text box - Ajax
auto complete text box  How to create auto complete text box in jsp using ajax technology ? plz giv me steps wise code
jsp fie execution in tomcat and using mysql - JDBC
jsp fie execution in tomcat and using mysql  I created 2 jsp files..., There is a problem in both JSP pages. If you want to login,try the following code: 1... and password to enter into the Mysql database account.the other named
need help...................please
need help...................please  I have a problem in my JSP Coding... on this area. Please help me. By the way, I'm using access Database and JSP coding... || xmlHttp.readyState=="complete") { var showdata = xmlHttp.responseText; var strar
Auto Complete Text Box - JSP-Servlet
Auto Complete Text Box - JSP-Servlet  Auto Complete Text Box Please help me in Aotocomplete text box code. I m a java programmer. I m working on jsp tech. please give me the code for Autocomplete text box in which the values
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
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
managing the transactions
should i write in EJB (i am using SEAM) to manage the transactions...managing the transactions  HI i am using JSF and SEAM and Hibernate when i search the record in JSF page , it dispalys all the records regarding
Creating Hibernate Sessions and Transactions through Spring - AOP .
and Transactions using Spring-AOP. Can you provide a sample code where Hibernate Sessions and Transactions are created using Spring-AOP when the control flows...Creating Hibernate Sessions and Transactions through Spring - AOP .  
Creating Hibernate Sessions and Transactions through Spring - AOP .
and Transactions using Spring-AOP. Can you provide a sample code where Hibernate Sessions and Transactions are created using Spring-AOP when the control flows...Creating Hibernate Sessions and Transactions through Spring - AOP .  
Creating Hibernate Sessions and Transactions through Spring - AOP .
and Transactions using Spring-AOP. Can you provide a sample code where Hibernate Sessions and Transactions are created using Spring-AOP when the control flows...Creating Hibernate Sessions and Transactions through Spring - AOP .  
Creating Hibernate Sessions and Transactions through Spring - AOP .
and Transactions using Spring-AOP. Can you provide a sample code where Hibernate Sessions and Transactions are created using Spring-AOP when the control flows...Creating Hibernate Sessions and Transactions through Spring - AOP .  
Creating Hibernate Sessions and Transactions through Spring - AOP .
and Transactions using Spring-AOP. Can you provide a sample code where Hibernate Sessions and Transactions are created using Spring-AOP when the control flows...Creating Hibernate Sessions and Transactions through Spring - AOP .  
paging in Jsp: jsp code - JSP-Servlet
. i want to perform paging in jsp file so that we don't need to scroll page... friend, pagination using jsp with database <...;Hi friend, Complete code for paging Do some changes 1.tablename
Complete Hibernate 4.0 Tutorial
Complete Hibernate 4.0 Tutorial Hibernate is a Object-relational mapping (ORM... and implementation classes, deprecated functions, classes clean up. Given below the complete... Application : Insert Record using Hibernate Save Method Hibernate 4
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
jsp and mysql
jsp and mysql  i have a form which contains dropdown list. i have to take the values to another jsp page and perform the calculation on the database which i have earlier using the values of the selected dropdown list
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...; Mysql database Table. Code to insert row in Mysql table : databaseinsertion.jsp
Connect JSP with mysql
you how to connect to MySQL database from your JSP code. First, you need... the jsp code you need to paste mySqlConnector.jar in lib directory of jdk... Connect JSP with mysql   
Connect JSP with mysql
with mysql : Now in the following jsp code, you will see how to connect... Connect JSP with mysql   ... named 'usermaster' in mysql. To create this database we need to run the following
Ajax Auto Complete Tutorial
complete with JQuery is given below, to run this example you need to import two...Auto Complete Example The auto complete feature helps the user to input... can give direct reference to these files Then you need to specify the input
excel report fro jsp mysql
excel report fro jsp mysql  Dear Sir, I am facing some problem while generating excel report form mysql database using jsp code. With the help from... data. But I need your help for generating a excel file from mysql DB for blob
Welcome to the MySQL Tutorials
;    Complete MySQL 5 Tutorial... using MySQL. In this online training/tutorial we are using MySQL 5.0... Using MYSQL Database This lesson is intended to provide hands
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
jsp,mysql - JSP-Servlet
jsp,mysql  hi i need a code to retrieve data to text boxes and move the records and also allow the user to change/delete the record SEMINARS THEME
Need help
using access database and jsp code. Thank you...Need help  Dear sir, I have a problem. How to write JSP coding, if a user select a value from drop down list for example department, the another drop
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
a class named Transactions
a class named Transactions  Write this java code for me: a class named Transactions that holds the memo and the amount of a transaction. Prompt the user for the number of transactions and create a new Transaction object
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
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
java beans code in jsp - WebSevices
java beans code in jsp  can you tell me how to use java beans in jsp in step wise. iam doing online banking project. i need java beans code connecting jsp page to mysql database. please send me the code for login page, myaccount
jsp code - JSP-Servlet
jsp code  I need code for bar charts using jsp. I searched some code but they are contain some of their own packages. Please give me asimple code... friend, Code to solve the problem : Thanks
JSP SQL Tag
and transactions. JSP pages can import this library with the following directive: <... in jsp. The code consists of taglib directive that allow the jsp page... using the tag <sql:query>. The code return the records from register table
Auto complete of word search using ajax with java
Auto complete of word search using ajax with java  I want to display the list of words when I type the first letter of the word in a text box. I am using jsp to design the form. I want ajax sample to achieve this feature. Its
Auto complete of word search using ajax with java
Auto complete of word search using ajax with java  I want to display the list of words when I type the first letter of the word in a text box. I am using jsp to design the form. I want ajax sample to achieve this feature. Its
No complete code for AbstractWizardFormCOntroller Example
No complete code for AbstractWizardFormCOntroller Example  No complete codes
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
JSP code
JSP code  I get an error when i execute the following code : <... = con.createStatement(); st.executeQuery(query); %> <jsp:forward page="address.jsp"></jsp:forward> HTTP Status 500 - type Exception report message
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
Auto Complete Text Box - JSP-Servlet
Auto Complete Text Box  Please help me in Aotocomplete text box code. I m a java programmer. I m working on jsp tech. please give me the code for Autocomplete text box in which the values will generate from database table
mysql
mysql  How can install My sql drivers using a jar File   Hi you need to download the mysql-connector jar file for connecting java program from mysql database.......   Hi friend, MySQL is open source database

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.