java图书商城源码(java图书系统源代码)
本文目录一览:
网络图书商城系统用java编写的源代码以及注释
关于图书Java商城系统可以了解下mcmore电商系统,源代码什么的咨询客服。
求java编程源代码,关于图书借阅系统的,
/
用户登陆数据库代码:
import java.sql.*;
class Database {
Connection con;
ResultSet rs;
Statement stmt;
public Database() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//
加载
JDBC-ODBC
桥驱动程序
String url = "jdbcdbc:HDB";
con = DriverManager.getConnection(url);
//
连接数据库
HDB //stmt
提供一个创建
SQL
查询、执行查询、得到返回结果
的空间
stmt =
// con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
// ResultSet.CONCUR_READ_ONLY);
} catch (Exception ex) {
System.out.println(ex);
}
}
/*
根据用户名,获取密码
*/
public String getPswd(String name) {
try {
// rs
为执行
SQL
语句所查询的结果赋给结果集对象
rs
rs = stmt.executeQuery("SELECT pswd FROM User WHERE Name = '"
+ name + "'");
rs.last();
//
把
rs
的指针移到最后一行
if (rs.getRow() == 0) {
return null;
} else {
String pswdDB = rs.getString("Pswd");
//
获取
rs
结果集中的
pswd
列的数据
return pswdDB;
}
} catch (Exception e) {
System.out.println(e);
return null;
}
}
/*
增加一行用户名、密码数据
*/
public boolean insertData(String name, String pswd) {
try {
String s = getPswd(name);
if (s == null) {
int rtn = stmt.executeUpdate("INSERT INTO User VALUES('" + name
+ "','" + pswd + "')");
if (rtn != 0)
return true;
} else {
return false;
}
return false;
} catch (Exception et) {
System.out.println(et);
return false;
}
}
}
//
进库数据库代码:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
class BookDatabase {
Connection con;
ResultSet rs;
Statement stmt;
public BookDatabase() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//
加载
JDBC-ODBC
桥驱动程序
String url = "jdbcdbc:Book";
con = DriverManager.getConnection(url);
//
连接数据库
HDB //stmt
提供一个创建
SQL
查询、执行查询、得到返回结果
的空间
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
} catch (Exception ex) {
System.out.println(ex);
}
}
/*
增加一行用户名、密码数据
*/
public boolean insertData(String id, String name, String where, String
price, String date) {
try {
int rtn = stmt.executeUpdate("INSERT INTO Book VALUES('" + id
+ "','"
+ name + "','" + where + "','" + price + "','" + date
+ "')");
if (rtn != 0) {
return true;
} else {
return false;
}
} catch (Exception et) {
System.out.println(et);
return false;
}
}
/*
* public boolean deleteData(String id){ try{ int rtn =
* stmt.executeUpdate("DELETE FROM Book WHERE id=001" ); if( rtn != 0 ){
* return true; } else{ return false; } } catch(Exception e){
* System.out.println( e ) return false; } } public boolean Select(String
* id){ try{ int rtn = stmt.executeUpdate("SELECT * FROM BookIn WHERE
* id='"+id+"'");
*
* if( rtn != 0 ){ return true; } else{ return false; } } catch(Exception
* e){ System.out.println( e ) return false; } }
*/
}
//
出库数据库代码:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
哪能下载java网上商城源码,并且可执行的
据我了解shop++是java类型的商城,有提供源代码,不过是一款需付费才能商用的软件。
求简单实现网上商城功能的java代码
平时在线10k人大概是让你创建一个数据库连接池,大小设置10k。
下面是一个图书商城的数据库表部分,供你参考
set utf8
DROP TABLE IF EXISTS d_product;
CREATE TABLE d_product (//用来存放总商品,入图书种类
id int(12) NOT NULL auto_increment,
product_name varchar(100) NOT NULL,
description varchar(100) default NULL,
add_time bigint(20) default NULL,
fixed_price double NOT NULL,
dang_price double NOT NULL,
keywords varchar(200) default NULL,
has_deleted int(1) NOT NULL default '0',
product_pic varchar(200) default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO d_product VALUES (23,'上课睡觉的故事','上课睡觉的故事',1237873000234,200,180,'key',0,'15.jpg');
DROP TABLE IF EXISTS d_book;
CREATE TABLE d_book (//用来存放图书的具体内容
id int(12) NOT NULL,
author varchar(200) NOT NULL,
publishing varchar(200) NOT NULL,
publish_time bigint(20) NOT NULL,
word_number varchar(15) default NULL,
which_edtion varchar(15) default NULL,
total_page varchar(15) default NULL,
print_time int(20) default NULL,
print_number varchar(15) default NULL,
isbn varchar(25) default NULL,
author_summary text NOT NULL,
catalogue text NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO d_book VALUES (24,'阿斗,'地球出版社',1237873000234,'1万','1','100',1,NULL,'12345678','无描述,'好书!');
DROP TABLE IF EXISTS d_category;
CREATE TABLE d_category (//商城图书目录
id int(12) NOT NULL auto_increment,
turn int(10) NOT NULL,
en_name varchar(200) NOT NULL,
name varchar(200) NOT NULL,
description varchar(200),
parent_id int(10),
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO d_category VALUES (1,1,'Book','图书',NULL,0);
DROP TABLE IF EXISTS d_category_product;
CREATE TABLE d_category_product (//这个是连接目录和书籍具体信息的表
id int(12) NOT NULL auto_increment,
product_id int(10) NOT NULL,
cat_id int(10) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO d_category_product VALUES (72,24,1);
DROP TABLE IF EXISTS d_item;
CREATE TABLE d_item (//这个订单条目表
id int(12) NOT NULL auto_increment,
order_id int(10) NOT NULL,
product_id int(10) NOT NULL,
product_name varchar(100) NOT NULL,
dang_price double NOT NULL,
product_num int(10) NOT NULL,
amount double NOT NULL,
PRIMARY KEY (id)
)
DROP TABLE IF EXISTS d_order;
CREATE TABLE d_order (//订单表
id int(10) NOT NULL auto_increment,
user_id int(10) NOT NULL,
status int(10) NOT NULL,
order_time bigint(20) NOT NULL,
order_desc varchar(100) default NULL,
total_price double NOT NULL,
receive_name varchar(100) default NULL,
full_address varchar(200) default NULL,
postal_code varchar(8) default NULL,
mobile varchar(20) default NULL,
phone varchar(20) default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB;
DROP TABLE IF EXISTS d_receive_address;
CREATE TABLE d_receive_address (//收件人信息表
id int(12) NOT NULL auto_increment,
user_id int(11) NOT NULL,
receive_name varchar(20) NOT NULL,
full_address varchar(200) NOT NULL,
postal_code varchar(8) NOT NULL,
mobile varchar(15) default NULL,
phone varchar(20) default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB;
insert into d_receive_address values(1, 6,'Java','sun.cn','10000800','12345','67890');
insert into d_receive_address values(2, 6,'JavaJavaJava','ibm.cn','10000600','12345','67890');
DROP TABLE IF EXISTS d_user;
CREATE TABLE d_user (//用户表,用户信息
id int(12) NOT NULL auto_increment,
email varchar(50) NOT NULL,
nickname varchar(50) default NULL,
password varchar(50) NOT NULL,
user_integral int(12) NOT NULL default '0',
is_email_verify char(3),
email_verify_code varchar(50) default NULL,
last_login_time bigint default NULL,
last_login_ip varchar(15) default NULL,
PRIMARY KEY (id),
UNIQUE KEY email (email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;