资源简介
基于javaweb的银行系统实现了银行转账存取款等功能
代码片段和文件信息
package db;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.text.*;
import model.*;
public class DatabaseConnection {
private Connection conn = null;
PreparedStatement pstmt = null;
private static final String DBDRIVER = “com.mysql.jdbc.Driver“;
private static final String DBURL = “jdbc:mysql://219.222.191.143:3306/jsp?user=jsp&password=123456789?useUnicode=true&characterEncoding=utf-8“;
private static final String DBUSER = “jsp“;
private static final String DBPASSWORD = “123456789“;
public DatabaseConnection() {
try{
Class.forName(DBDRIVER);
this.conn = DriverManager.getConnection(DBURL DBUSER DBPASSWORD);
}catch(Exception e){
e.printStackTrace();
}
}
public void close() throws Exception{
try{
if(this.conn != null){
this.conn.close();
}
}catch(Exception e){
throw e;
}
}
public int findRow(String table){
String newSQL = “SELECT * FROM “+ table ;
int count = 0;
ResultSet rs = null;
try{
pstmt = conn.prepareStatement(newSQL);
rs = pstmt.executeQuery();
while(rs.next()){
count++;
}
}catch(Exception e ){
e.printStackTrace();
}finally{
try{
rs.close();
pstmt.close();
}catch(Exception e){
e.printStackTrace();
}
}
return count;
}
public boolean addAccount(String username String password){
long id = this.findRow(“201141404203Account“) + 100000;
java.util.Date date = new java.util.Date(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss“);
String timeString = sdf.format(date);
try{
pstmt = conn.prepareStatement(“insert into 201141404203Account values (?????)“);
pstmt.setLong(1 id);
pstmt.setString(2username);
pstmt.setString(3 password);
pstmt.setString(4timeString );
pstmt.setDouble(5 0);
pstmt.executeUpdate();
return true;
}catch(Exception e){
e.printStackTrace();
return false;
}
}
public Account checkAccount(String id String password){
try{
pstmt = conn.prepareStatement(“select * from 201141404203Account where id=? and password=?“);
pstmt.setString(1 id);
pstmt.setString(2 password);
ResultSet rs = pstmt.executeQuery();
Account account = new Account();
if(rs.next())
{
account.setId(rs.getLong(1));
account.setUsername(rs.getString(2));
account.setPassword(rs.getString(3));
account.setRegisterTime(rs.getString(4));
account.setBalance(rs.getDouble(5));
return account;
}
return null;
}catch(Exception e){
e.printStackTrace();
return null;
}
}
public double findBalance(long id){
String sql = “select * from 201141404203Account WHERE id=“ + id ;
try{
pstmt = conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
if(rs.next()){
return rs.getDouble(5);
}else{
return -1; //发生异常时返回-1
}
}c
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 727 2013-07-04 00:11 Bank\.classpath
文件 1045 2013-06-11 16:26 Bank\.project
文件 503 2013-06-11 16:26 Bank\.settings\.jsdtscope
文件 147 2013-06-27 20:52 Bank\.settings\org.eclipse.core.resources.prefs
文件 395 2013-06-11 16:26 Bank\.settings\org.eclipse.jdt.core.prefs
文件 490 2013-06-11 16:26 Bank\.settings\org.eclipse.wst.common.component
文件 305 2013-07-04 00:10 Bank\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2013-06-11 16:26 Bank\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2013-06-11 16:26 Bank\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 9045 2013-07-04 00:11 Bank\build\classes\db\Databa
文件 1321 2013-07-04 00:11 Bank\build\classes\model\Account.class
文件 1681 2013-07-04 00:11 Bank\build\classes\model\Record.class
文件 2125 2013-07-04 00:11 Bank\build\classes\servlet\DepositServlet.class
文件 1870 2013-07-04 00:11 Bank\build\classes\servlet\InfoServlet.class
文件 706 2013-07-04 00:11 Bank\build\classes\servlet\InterestServlet$1.class
文件 1384 2013-07-04 00:11 Bank\build\classes\servlet\InterestServlet.class
文件 2250 2013-07-04 00:11 Bank\build\classes\servlet\LoginServlet.class
文件 1321 2013-07-04 00:11 Bank\build\classes\servlet\LogoutServlet.class
文件 1988 2013-07-04 00:11 Bank\build\classes\servlet\ModifyServlet.class
文件 2187 2013-07-04 00:11 Bank\build\classes\servlet\RecordServlet.class
文件 2085 2013-07-04 00:11 Bank\build\classes\servlet\RegisterServlet.class
文件 2140 2013-07-04 00:11 Bank\build\classes\servlet\WithdrawServlet.class
文件 8357 2013-07-02 23:42 Bank\src\db\Databa
文件 849 2013-06-26 18:26 Bank\src\model\Account.java
文件 1065 2013-06-17 18:56 Bank\src\model\Record.java
文件 1823 2013-07-02 14:03 Bank\src\servlet\DepositServlet.java
文件 1667 2013-06-18 13:28 Bank\src\servlet\InfoServlet.java
文件 1637 2013-07-02 14:05 Bank\src\servlet\InterestServlet.java
文件 1802 2013-07-02 09:25 Bank\src\servlet\LoginServlet.java
文件 1358 2013-06-28 23:39 Bank\src\servlet\LogoutServlet.java
............此处省略184个文件信息
- 上一篇:银联Ecb加密算法
- 下一篇:MagicDraw 16.8 破解补丁 免积分
评论
共有 条评论