平时在线10k人大概是让你创建一个数据库连接池,大小设置10k.
下面是一个图书商城的数据库表部分,供你参考
DROP TABLE IF EXISTS d_product;
CREATE TABLE d_product (//用来存放总商品,入图书种类
product_name varchar(100) NOT NULL,
description varchar(100) default NULL,
fixed_price double NOT NULL,
dang_price double NOT NULL,
has_deleted int(1) NOT NULL default '0',
PRIMARY KEY (id)
DROP TABLE IF EXISTS d_book;
CREATE TABLE d_book (//用来存放图书的具体内容
author_summary text NOT NULL,
catalogue text NOT NULL,
DROP TABLE IF EXISTS d_category;
CREATE TABLE d_category (//商城图书目录
turn int(10) NOT NULL,
parent_id int(10),
INSERT INTO d_category VALUES (1,1,'Book','图书',NULL,0);
DROP TABLE IF EXISTS d_category_product;
CREATE TABLE d_category_product (//这个是连接目录和书籍具体信息的表
product_id int(10) NOT NULL,
cat_id int(10) NOT NULL,
DROP TABLE IF EXISTS d_item;
CREATE TABLE d_item (//这个订单条目表
order_id int(10) NOT NULL,
product_num int(10) NOT NULL,
amount double NOT NULL,
)
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_desc varchar(100) default NULL,
total_price double NOT NULL,
receive_name varchar(100) default NULL,
) ENGINE=InnoDB;
DROP TABLE IF EXISTS d_receive_address;
CREATE TABLE d_receive_address (//收件人信息表
user_id int(11) NOT NULL,
DROP TABLE IF EXISTS d_user;
CREATE TABLE d_user (//用户表,用户信息
last_login_time bigint default NULL,
PRIMARY KEY (id),
UNIQUE KEY email (email)
package com.company.dao;
import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;public class BaseDao {
// 数据库驱动
String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
//url
String url = "jdbc:sqlserver://数据库ip:端口号;databaseName=数据库名;";
//用户名
String uname = "数据库用户名";
//密码
String pwd = "数据库密码";
/**
* 获得连接对象
* @return
*/
protected Connection getCon(){
//返回的连接
Connection con = null;
try {
//载入驱动
Class.forName(driver);
//得到连接
con = DriverManager.getConnection(url, uname, pwd);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
}
return con;
* 关闭数据库
* @param con
* @param stmt
* @param rs
protected void closeDB(Connection con, Statement stmt, ResultSet rs){
if(rs != null){
//关闭结果集
rs.close();
rs = null;
if(stmt != null){
//关闭语句对象
stmt.close();
stmt = null;
if(con != null){
//关闭连接对象
con.close();
con = null;
protected void closeDB(Connection con, PreparedStatement pstmt, ResultSet rs){
if(pstmt != null){
pstmt.close();
pstmt = null;
详细代码写出来很长,我写一个思路
①.:前台传商品名称,类别,价格等多个属性信息
String?where?=?"where?1=1";
//迭代map
最后得出的where条件就是 ?where 1=1 or name='xxx' ?or age=xx or xx=xx
就可以搜索到前台需要的商品
算是最简单的吧
package cn.job01;
import java.util.Scanner;
public static void choice() {
System.out.println("登陆菜单 ");
System.out.println("1登陆系统");
static void choice1() {
System.out.println("购物管理系统客户信息");
System.out.println("1显示所有客户信息");
System.out.println("购物管理系统真情回馈");
System.out.println("1幸运大放送");
public static void main(String[] args) {
choice();
Scanner input = new Scanner(System.in);
int num = input.nextInt();
switch (num) {
case 1:
System.out.println("主菜单");
System.out.println("1客户信息管理");
break;
System.out.println("选择输入数字");
int num1 = input.nextInt();
switch (num1) {
choice1();
System.out.println("购物结算");
以上就是土嘎嘎小编为大家整理的java商品系统代码相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!