「物流跟踪管理系统,java资深工程师面试题


DROP TABLE IF EXISTS tb_order;

CREATE TABLE tb_order (

id int(11) NOT NULL AUTO_INCREMENT,

name varchar(20) NOT NULL,

price decimal(10,2) NOT NULL,

orderid varchar(20) DEFAULT NULL,

descinfo varchar(100) DEFAULT NULL,

PRIMARY KEY (id)

) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;


– Records of tb_order


INSERT INTO tb_order VALUES (‘1’, ‘iphones Max’, ‘8999.00’, ‘5325781’, ‘杨明金的订单’);

INSERT INTO tb_order VALUES (‘2’, ‘小米10’, ‘3655.00’, ‘20201005’, ‘杨杨的订单’);

INSERT INTO tb_order VALUES (‘3’, ‘华为荣耀10 =’, ‘3200.00’, ‘20201102’, ‘小白的订单’);

二、Java Swing


com.ynavc.Bean

tb_order.java

package com.ynavc.Base;

public class tb_order {

private int id;

private String name;

private double price;

private int orderID;

private String descinfo;

public tb_order() {

super();

}

public tb_order(int id, String name, double price, int orderID, String descinfo) {

super();

this.id = id;

this.name = name;

this.price = price;

this.orderID = orderID;

this.descinfo = descinfo;

}

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public double getPrice() {

return price;

}

public void setPrice(double price) {

this.price = price;

}

public int getOrderID() {

return orderID;

}

public void setOrderID(int orderID) {

this.orderID = orderID;

}

public String getDescinfo() {

return descinfo;

}

public void setDescinfo(String descinfo) {

this.descinfo = descinfo;

}

}

com.ynavc.BaseDAO

DbConnection.java

package com.ynavc.BaseDAO;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import javax.swing.JOptionPane;

import com.mysql.jdbc.Statement;

public class DbConnection {

//驱动类的类名

private static final String DRIVERNAME=“com.mysql.jdbc.Driver”;

//连接数据的URL路径

private static final String URL=“jdbc:mysql://127.0.0.1:3306/orderdb”;

//数据库登录账号

private static final String USER=“root”;

//数据库登录密码

private static final String PASSWORD=“root123”;

//加载驱动

static{

try {

Class.forName(DRIVERNAME);

} catch (ClassNotFoundException e) {

e.printStackTrace();

}

}

//获取数据库连接

public static Connection getConnection() {

try {

return DriverManager.getConnection(URL,USER,PASSWORD);

} catch (SQLException e) {

e.printStackTrace();

}

return null;

}

//查询

public static ResultSet query(String sql) {

System.out.println(sql);

//获取连接

Connection connection=getConnection();

PreparedStatement psd;

try {

psd = connection.prepareStatement(sql);

return psd.executeQuery();

} catch (SQLException e) {

JOptionPane.showMessageDialog(null,“执行语句出错\n”+e.toString());

e.printStackTrace();

}

return null;

}

//增、删、改、查

public static int updataInfo(String sql) {

System.out.println(sql);

//获取连接

Connection connection=getConnection();

try {

PreparedStatement psd=connection.prepareStatement(sql);

return psd.executeUpdate();

} catch (SQLException e) {

JOptionPane.showMessageDialog(null,“执行语句出错\n”+e.toString());

e.printStackTrace();

}

return 0;

}

//关闭连接

public static void colse(ResultSet rs,Statement stmt,Connection conn) throws Exception{

try {

if (rs != null){

rs.close();

}

if (stmt != null){

stmt.cancel();

}

if (conn != null) { conn.close(); }

} catch (Exception e) {

e.printStackTrace(); throw new Exception();

}

}

}

com.ynavc.OrderDAO

Update.java

package com.ynavc.OrderDAO;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.ArrayList;

import com.ynavc.Base.tb_order;

import com.ynavc.BaseDAO.DbConnection;

public class Update {

//查询主页信息

public Object[][] getMainInfo(String id) {

String sql;

if (id.equals(“”)) {

sql = “select * from tb_order”;

}else {

sql = “select * from tb_order WHERE orderid LIKE '”+id+“%';”;

}

ResultSet re = DbConnection.query(sql);

ArrayList<tb_order> list = new ArrayList<tb_order>();

try {

while (re.next()) {

tb_order tb = new tb_order();

tb.setId(re.getInt(1));

tb.setName(re.getString(2));

tb.setPrice(re.getDouble(3));

tb.setOrderID(re.getInt(4));

tb.setDescinfo(re.getString(5));

list.add(tb);

}

} catch (SQLException e) {

e.printStackTrace();

}

Object[][] ob = new Object[list.size()][5];

for (int i = 0; i < list.size(); i++) {

ob[i][0] = list.get(i).getId();

ob[i][1] = list.get(i).getName();

ob[i][2] = list.get(i).getPrice();

ob[i][3] = list.get(i).getOrderID();

ob[i][4] = list.get(i).getDescinfo();

}

return ob;

}

//删除数据

public int addData(int id) {

String sql = “DELETE FROM tb_order WHERE id='”+id+“';”;

return DbConnection.updataInfo(sql);

}

}

com.ynavc.Vive

MainFrame.java

小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级Java工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Java开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频

如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Java)
img

业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。**

深知大多数初中级Java工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Java开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
[外链图片转存中…(img-UMFo6327-1710848110756)]
[外链图片转存中…(img-BFc2b0Mw-1710848110756)]
[外链图片转存中…(img-jJcrq9Df-1710848110757)]

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频

如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Java)
[外链图片转存中…(img-IWRydTWG-1710848110757)]

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值