图书管理系统java版

本文的目的就是通过图书管理系统掌握数据库编程技术,能正确连接数据库,能对数据库中信息进行查询、插入、删除、修改。
内容:在数据库中创建一张书目信息表,包括书名、作者、出版社、出版日期、书号、价格字段。设计一个GUI界面进行书目管理。在该界面上有四个选项卡,分别是查询、插入、删除、修改。点击查询选项卡,出现的界面上有书名、作者、出版社、书号四个文本框,一个按钮和一个只读文本区。文本框内容可以为空,输入相应的查询信息后(例如根据书名查询可以仅输入书名),点击界面上的“查询”按钮,可以在界面下方的文本区中显示出符合条件的书目详细信息。点击插入选项卡,出现的界面上有书名、作者、出版社、出版日期、书号、价格文本框,一个按钮。在文本框中输入信息后,点击“插入”按钮,该书目信息插入数据库表中。点击删除选项卡,出现的界面上有书名文本框和一个按钮,输入书名后点击“删除”按钮,该书目信息从数据库表中删除。点击修改选项卡,出现的界面上有书名、作者、出版社、出版日期、书号、价格文本框,一个按钮。输入的书名必须是已存在的,否则会弹出消息框显示出错信息。输入信息后,点击“修改”按钮,数据库表中的相应书目信息被修改为新值。
源码:

BookInfo.java

 * 项目名称:图书管理系统 
 * 版本: 1.0 
 * 创建者: 张俊强 
 * 创建时间:2016/5/26 
 * */ 
package librarySystem; 
 
import java.awt.*; 
 
import javax.swing.*; 
 
import java.awt.event.*; 
import java.sql.*; 
 
@SuppressWarnings("serial") 
public class BookInfo extends JFrame implements ActionListener{ 
 //主角面上的控件 
 private JLabel inputLabel; 
 private JTextField inputText; 
 private JButton searchBut; 
 
 private JTable bookTable; 
 private JScrollPane bookScroll; 
 private JButton addBut; 
 private JButton modifyBut; 
 private JButton deleteBut; 
 private JButton refreshBut; 
 private BookTableModel bookTableModel; 
 public static void main(String[] args) throws SQLException { 
  // TODO Auto-generated method stub 
  BookInfo bookInfo=new BookInfo(); 
  bookInfo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
  bookInfo.setBounds(350,150,600,400); 
  bookInfo.setVisible(true); 
//  bookInfo.importSQL();//导出数据 
  bookInfo.setMinWindowLayout();//设置数据 
 } 
 public BookInfo() throws SQLException{ 
  //创建主界面上的控件 
  inputLabel=new JLabel("请输入书名:"); 
  inputText=new JTextField(10); 
  searchBut=new JButton("查询"); 
  bookTableModel=new BookTableModel(); 
   
  bookTable=new JTable(bookTableModel); 
  bookScroll=new JScrollPane(bookTable); 
   
  addBut=new JButton("添加"); 
  modifyBut=new JButton("修改"); 
  deleteBut=new JButton("删除"); 
  refreshBut=new JButton("刷新"); 
  searchBut.addActionListener(this); 
  addBut.addActionListener(this); 
  refreshBut.addActionListener(this); 
  modifyBut.addActionListener(this); 
  deleteBut.addActionListener(this); 
 
 } 
 
 void setMinWindowLayout(){ 
  //主界面布局 
  Container con1=new Container(); 
  con1.setLayout(new FlowLayout()); 
  con1.add(inputLabel); 
  con1.add(inputText); 
  con1.add(searchBut); 
  con1.add(refreshBut); 
  Container con2=new Container(); 
  con2.setLayout(new FlowLayout()); 
  con2.add(addBut); 
  con2.add(modifyBut); 
  con2.add(deleteBut); 
  this.setLayout(new BorderLayout()); 
  this.add(con1,BorderLayout.NORTH); 
  this.add(bookScroll,BorderLayout.CENTER); 
  this.add(con2,BorderLayout.SOUTH); 
  this.validate(); 
 } 
 @Override 
 public void actionPerformed(ActionEvent e) { 
  // TODO Auto-generated method stub 
  if(e.getSource()==searchBut){ 
   if(!this.inputText.getText().equals("")){ 
    String bookName=this.inputText.getText(); 
    String sql="SELECT * FROM book_info WHERE book_name ='"+bookName+"'"; 
    try { 
    bookTableModel=new BookTableModel(sql); 
    bookTable.setModel(bookTableModel); 
   } catch (SQLException e1) { 
    // TODO Auto-generated catch block 
    e1.printStackTrace(); 
   } 
     
   }else{ 
    JOptionPane.showMessageDialog(this,"输入不能为空","提示",JOptionPane.PLAIN_MESSAGE); 
   } 
  } 
  else if(e.getSource()==addBut){ 
   @SuppressWarnings("unused") 
   AddBookDialog addWin=new AddBookDialog(this,"添加图书",true); 
   this.refreshTable(); 
  } 
  else if(e.getSource()==refreshBut){ 
   this.refreshTable(); 
  } 
  else if(e.getSource()==deleteBut){ 
   int rowNum=bookTable.getSelectedRow(); 
   if(rowNum<0||rowNum>bookTable.getRowCount()){    
    JOptionPane.showMessageDialog(this,"未选中",JOptionPane.PLAIN_MESSAGE); 
   } 
   else{ 
    //System.out.print(bookName); 
    int n = JOptionPane.showConfirmDialog(null,"确认删除吗?","确认删除框",JOptionPane.YES_NO_OPTION); 
    if (n == JOptionPane.YES_OPTION) { 
     String bookNum=(String) bookTable.getValueAt(rowNum,0); 
     String sql="DELETE FROM book_info WHERE book_num= '"+bookNum+"'"; 
     bookTableModel.deleteBook(sql); 
     this.refreshTable(); 
     JOptionPane.showMessageDialog(this,"删除成功",JOptionPane.PLAIN_MESSAGE); 
    } else if (n == JOptionPane.NO_OPTION) { 
     return; 
    } 
   } 
  } 
  else if(e.getSource()==modifyBut){ 
   bookTable.setModel(bookTableModel); 
   int rowNum=bookTable.getSelectedRow(); 
   if(rowNum<0||rowNum>bookTable.getRowCount()){    
    JOptionPane.showMessageDialog(this,JOptionPane.PLAIN_MESSAGE); 
   } 
   else{ 
    @SuppressWarnings("unused") 
    ModifyBook modifyWin=new ModifyBook(this,"修改信息",true,bookTableModel,rowNum); 
    this.refreshTable(); 
   } 
  } 
   
 } 
 public void refreshTable(){ 
  BookTableModel searchBook; 
  try { 
   searchBook = new BookTableModel("SELECT * FROM book_info"); 
   bookTable.setModel(searchBook); 
   bookTableModel=searchBook; 
  } catch (SQLException e1) { 
   // TODO Auto-generated catch block 
   e1.printStackTrace(); 
  } 
 } 
} 

BookTableModel.java

package librarySystem; 
import java.sql.*; 
import java.util.*; 
 
/* 
 * 图书表模型 
 * */ 
import javax.swing.table.*; 
@SuppressWarnings("serial") 
public class BookTableModel extends AbstractTableModel{ 
 //表的元素 
 private Vector<Vector<String>> rowData; 
 private Vector<String> colName; 
 // 数据库 
 private PreparedStatement stmt; 
 private ResultSet result; 
 public BookTableModel(String sql) throws SQLException{ 
  this.initData(sql); 
 } 
 public BookTableModel() throws SQLException{ 
  this.initData("SELECT * FROM book_info"); 
 } 
 public void initData(String sql) throws SQLException{ 
  setRowData(new Vector<Vector<String>>()); 
  setColName(new Vector<String>()); 
  getColName().add("书号"); 
  getColName().add("书名"); 
  getColName().add("作者"); 
  getColName().add("出版社"); 
  getColName().add("出版时间"); 
  getColName().add("价格"); 
  /* 
   * 数据库的导入 
   * */ 
  try { 
   Class.forName("com.mysql.jdbc.Driver"); 
  } catch (ClassNotFoundException e) { 
   // TODO Auto-generated catch block 
   e.printStackTrace(); 
  } 
  String url= "jdbc:mysql://localhost:3306/device"; 
  String user="root"; 
  String password="zjq1314520"; 
  Connection con=DriverManager.getConnection(url,user,password); 
  stmt = con.prepareStatement(sql); 
  result=stmt.executeQuery(); 
  importSQL(); 
 } 
 void importSQL() throws SQLException{ 
  // TODO Auto-generated method stub 
  @SuppressWarnings("unused") 
  boolean signNull=true; 
  while(result.next()){ 
   Vector<String> item=new Vector<String>(); 
   for(int i=1;i<7;i++){ 
    item.add(result.getString(i)); 
   } 
   getRowData().add(item); 
   signNull=false; 
  } 
  result.close(); 
 } 
 @Override 
 public int getColumnCount() {//得到列数 
  // TODO Auto-generated method stub 
  return this.colName.size(); 
 } 
 
 @Override 
 public int getRowCount() {//得到行数 
  // TODO Auto-generated method stub 
  return this.rowData.size(); 
 } 
 
 @Override 
 public Object getValueAt(int row,int col) {//得到某行某列的数据 
  // TODO Auto-generated method stub 
  return (this.rowData.get(row)).get(col); 
 } 
 
 @Override 
 public String getColumnName(int column) { 
  // TODO Auto-generated method stub 
  return this.colName.get(column); 
 } 
  
 public Vector<Vector<String>> getRowData() { 
  return rowData; 
 } 
 public void setRowData(Vector<Vector<String>> rowData) { 
  this.rowData = rowData; 
 } 
 public Vector<String> getColName() { 
  return colName; 
 } 
 public void setColName(Vector<String> colName) { 
  this.colName = colName; 
 } 
 public void addBook(String sql){ 
  try { 
   stmt.executeUpdate(sql); 
  } catch (SQLException e) { 
   // TODO Auto-generated catch block 
   e.printStackTrace(); 
  } 
//  initData("SELECT * FROM book_info"); 
 } 
 public void deleteBook(String sql){ 
  try { 
   stmt.executeUpdate(sql); 
  } catch (SQLException e1) { 
   // TODO Auto-generated catch block 
   e1.printStackTrace(); 
  } 
 } 
} 

AddBookDialog.java

package librarySystem; 
 
import java.awt.*; 
import java.awt.event.*; 
import java.sql.SQLException; 
 
import javax.swing.*; 
 
@SuppressWarnings("serial") 
public class AddBookDialog extends JDialog implements ActionListener{ 
 private JLabel bookNumLabel; 
 private JLabel bookNameLabel; 
 private JLabel bookWriterLabel; 
 private JLabel bookPublishLabel; 
 private JLabel bookPriceLabel; 
 private JLabel bookTimeLabel; 
 private JTextField bookNumText; 
 private JTextField bookNameText; 
 private JTextField bookWriterText; 
 private JTextField bookPublishText; 
 private JTextField bookPriceText; 
 private JTextField bookTimeText; 
  
 private JButton submitBut; 
 private JButton cancelBut; 
 public AddBookDialog(Frame owner,String title,boolean model){ 
  //父窗口,窗口名,是否是模式窗口 
  super(owner,title,model); 
  bookNumLabel=new JLabel("书 号:"); 
  bookNameLabel=new JLabel("书 名:"); 
  bookWriterLabel=new JLabel("作 者:"); 
  bookPublishLabel=new JLabel("出版社:"); 
  bookPriceLabel=new JLabel("价 格:"); 
  bookTimeLabel=new JLabel("出版时间:"); 
   
  bookNumText=new JTextField(10); 
  bookNameText=new JTextField(10); 
  bookWriterText=new JTextField(10); 
  bookPublishText=new JTextField(10); 
  bookPriceText=new JTextField(10); 
  bookTimeText=new JTextField(9); 
   
  submitBut=new JButton("确认"); 
  cancelBut=new JButton("取消"); 
  submitBut.addActionListener(this); 
  cancelBut.addActionListener(this); 
  this.setBounds(350,400,260); 
  this.setResizable(false); 
  this.setLayout(new BorderLayout()); 
  initLayout(); 
 } 
 public void initLayout(){ 
  Container[] con1=new Container[6]; 
  for(int i=0;i<6;i++) con1[i]=new Container(); 
  con1[0].setLayout(new FlowLayout()); 
  con1[0].add(bookNumLabel); 
  con1[0].add(bookNumText); 
   
  con1[1].setLayout(new FlowLayout()); 
  con1[1].add(bookNameLabel); 
  con1[1].add(bookNameText); 
   
  con1[2].setLayout(new FlowLayout()); 
  con1[2].add(bookWriterLabel); 
  con1[2].add(bookWriterText); 
   
  con1[3].setLayout(new FlowLayout()); 
  con1[3].add(bookPublishLabel); 
  con1[3].add(bookPublishText); 
   
  con1[4].setLayout(new FlowLayout()); 
  con1[4].add(bookPriceLabel); 
  con1[4].add(bookPriceText); 
   
  con1[5].setLayout(new FlowLayout()); 
  con1[5].add(bookTimeLabel); 
  con1[5].add(bookTimeText); 
   
  Container con2=new Container(); 
  con2.setLayout(new BorderLayout()); 
  con2.add(con1[0],BorderLayout.NORTH); 
  con2.add(con1[1],BorderLayout.CENTER); 
  con2.add(con1[2],BorderLayout.SOUTH); 
   
  Container con3=new Container(); 
  con3.setLayout(new BorderLayout()); 
  con3.add(con1[3],BorderLayout.NORTH); 
  con3.add(con1[4],BorderLayout.CENTER); 
  con3.add(con1[5],BorderLayout.SOUTH); 
   
  Container con4=new Container(); 
  con4.setLayout(new FlowLayout()); 
  con4.add(submitBut); 
  con4.add(cancelBut); 
  Container con5=new Container(); 
  con5.setLayout(new BorderLayout()); 
  con5.add(con2,BorderLayout.NORTH); 
  con5.add(con3,BorderLayout.CENTER); 
  con5.add(con4,BorderLayout.SOUTH); 
   
  this.add(con5,BorderLayout.CENTER); 
  this.validate(); 
  this.setVisible(true); 
 } 
 @Override 
 public void actionPerformed(ActionEvent e) { 
  // TODO Auto-generated method stub 
  if(e.getSource()==submitBut){ 
   if(bookNumText.getText().equals("")||bookNameText.getText().equals("")|| 
     bookWriterText.getText().equals("")||bookPublishText.getText().equals("")|| 
     bookPriceText.getText().equals("")||bookTimeText.getText().equals("")){ 
    //System.out.println("输入失败"); 
    JOptionPane.showMessageDialog(this,"输入不能有空",JOptionPane.PLAIN_MESSAGE); 
   } 
   else{ 
    //System.out.println("输入成功"); 
    String sql="insert into " 
      + "book_info(book_num,book_name,book_writer,publish_house,book_price,publish_time)" 
      + "values('"+bookNumText.getText()+"','"+bookNameText.getText()+"','"+bookWriterText.getText()+"','"+bookPublishText.getText()+"','"+bookPriceText.getText()+"','"+bookTimeText.getText()+"')"; 
    try { 
     BookTableModel book=new BookTableModel(); 
     book.addBook(sql); 
    } catch (SQLException e1) { 
     // TODO Auto-generated catch block 
     e1.printStackTrace(); 
    } 
    JOptionPane.showMessageDialog(this,"添加成功",JOptionPane.PLAIN_MESSAGE); 
    this.setVisible(false); 
   } 
  } 
  if(e.getSource()==cancelBut){ 
   this.setVisible(false); 
  } 
 } 
} 

ModifyBook.java

package librarySystem; 
 
import java.awt.*; 
import java.awt.event.*; 
import java.sql.SQLException; 
import javax.swing.*; 
 
@SuppressWarnings("serial") 
public class ModifyBook extends JDialog implements ActionListener{ 
 private JLabel bookNumLabel; 
 private JLabel bookNameLabel; 
 private JLabel bookWriterLabel; 
 private JLabel bookPublishLabel; 
 private JLabel bookPriceLabel; 
 private JLabel bookTimeLabel; 
 private JTextField bookNumText; 
 private JTextField bookNameText; 
 private JTextField bookWriterText; 
 private JTextField bookPublishText; 
 private JTextField bookPriceText; 
 private JTextField bookTimeText; 
 private JButton submitBut; 
 private JButton cancelBut; 
 private BookTableModel bookModel; 
 private int rowNum; 
 public ModifyBook(Frame owner,boolean type,BookTableModel model,int row){ 
  super(owner,type); 
  bookModel=model; 
  rowNum=row; 
  bookNumLabel=new JLabel("书 号:"); 
  bookNameLabel=new JLabel("书 名:"); 
  bookWriterLabel=new JLabel("作 者:"); 
  bookPublishLabel=new JLabel("出版社:"); 
  bookPriceLabel=new JLabel("价 格:"); 
  bookTimeLabel=new JLabel("出版时间:"); 
   
  bookNumText=new JTextField(10); 
  bookNameText=new JTextField(10); 
  bookWriterText=new JTextField(10); 
  bookPublishText=new JTextField(10); 
  bookPriceText=new JTextField(10); 
  bookTimeText=new JTextField(9); 
   
  submitBut=new JButton("确认修改"); 
  cancelBut=new JButton("取消"); 
  submitBut.addActionListener(this); 
  cancelBut.addActionListener(this); 
  this.setBounds(350,260); 
  this.setResizable(false); 
  this.setLayout(new BorderLayout()); 
  this.setValue(); 
  this.initLayout(); 
   
 } 
 public void initLayout(){ 
  Container[] con1=new Container[6]; 
  for(int i=0;i<6;i++) con1[i]=new Container(); 
  con1[0].setLayout(new FlowLayout()); 
  con1[0].add(bookNumLabel); 
  con1[0].add(bookNumText); 
   
  con1[1].setLayout(new FlowLayout()); 
  con1[1].add(bookNameLabel); 
  con1[1].add(bookNameText); 
   
  con1[2].setLayout(new FlowLayout()); 
  con1[2].add(bookWriterLabel); 
  con1[2].add(bookWriterText); 
   
  con1[3].setLayout(new FlowLayout()); 
  con1[3].add(bookPublishLabel); 
  con1[3].add(bookPublishText); 
   
  con1[4].setLayout(new FlowLayout()); 
  con1[4].add(bookPriceLabel); 
  con1[4].add(bookPriceText); 
   
  con1[5].setLayout(new FlowLayout()); 
  con1[5].add(bookTimeLabel); 
  con1[5].add(bookTimeText); 
   
  Container con2=new Container(); 
  con2.setLayout(new BorderLayout()); 
  con2.add(con1[0],BorderLayout.SOUTH); 
  this.add(con5,BorderLayout.CENTER); 
  this.validate(); 
  this.setVisible(true); 
 } 
 public void setValue(){ 
  this.bookNumText.setText((String) bookModel.getValueAt(rowNum,0)); 
  this.bookNumText.setEditable(false); 
   
  this.bookNameText.setText((String) bookModel.getValueAt(rowNum,1)); 
  this.bookWriterText.setText((String) bookModel.getValueAt(rowNum,2)); 
  this.bookPublishText.setText((String) bookModel.getValueAt(rowNum,3)); 
  this.bookTimeText.setText((String) bookModel.getValueAt(rowNum,4)); 
  this.bookPriceText.setText((String) bookModel.getValueAt(rowNum,5)); 
  this.validate(); 
 } 
 @Override 
 public void actionPerformed(ActionEvent e) { 
 // System.out.println(bookPriceText.getText()); 
  // TODO Auto-generated method stub 
  if(e.getSource()==submitBut){ 
   if(bookNumText.getText().equals("")||bookNameText.getText().equals("")|| 
     bookWriterText.getText().equals("")||bookPublishText.getText().equals("")|| 
     bookPriceText.getText().equals("")||bookTimeText.getText().equals("")){ 
    //System.out.println("输入失败"); 
    JOptionPane.showMessageDialog(this,"修改不能有空",JOptionPane.PLAIN_MESSAGE); 
   } 
   else{ 
    int n = JOptionPane.showConfirmDialog(null,"确认修改吗?","确认修改框",JOptionPane.YES_NO_OPTION); 
    if (n == JOptionPane.YES_OPTION) { 
     String sql="UPDATE book_info SET book_name ='"+bookNameText.getText()+"',book_writer= '"+bookWriterText.getText()+"',publish_house='"+bookPublishText.getText()+"',book_price='"+bookPriceText.getText()+"',publish_time='"+bookTimeText.getText()+"' WHERE book_num = '"+bookNumText.getText()+"' "; 
     try { 
      BookTableModel book=new BookTableModel(); 
      book.addBook(sql); 
     } catch (SQLException e1) { 
      // TODO Auto-generated catch block 
      e1.printStackTrace(); 
     } 
     JOptionPane.showMessageDialog(this,"修改成功",JOptionPane.PLAIN_MESSAGE); 
     this.setVisible(false); 
    } else if (n == JOptionPane.NO_OPTION) { 
     return; 
    } 
   } 
  } 
  if(e.getSource()==cancelBut){ 
   this.setVisible(false); 
  } 
 }  
} 

程序运行结果:
主界面:

查询界面:

添加图书界面:

修改界面:

删除操作:

数据库界面:

关于管理系统的更多内容请点击《管理系统专题》进行学习

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程小技巧。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


本文从从Bitcask存储模型讲起,谈轻量级KV系统设计与实现。从来没有最好的K-V系统,只有最适合应用业务实际场景的系统,做任何的方案选择,要结合业务当前的实际情况综合权衡,有所取有所舍。
内部的放到gitlab pages的博客,需要统计PV,不蒜子不能准确统计,原因在于gitlab的host设置了strict-origin-when-cross-origin, 导致不蒜子不能正确获取referer,从而PV只能统计到网站的PV。 为了方便统计页面的PV,这里简单的写了一个java程
PCM 自然界中的声音非常复杂,波形极其复杂,通常我们采用的是脉冲代码调制编码,即PCM编码。PCM通过抽样、量化、编码三个步骤将连续变化的模拟信号转换为数字编码。 采样率 采样频率,也称为采样速度或者采样率,定义了每秒从连续信号中提取并组成离散信号的采样个数,它用赫兹(Hz)来表示。采样频率的倒数
本文介绍如何离线生成sst并在线加载,提供一种用rocksdb建立分布式kv系统替换mongodb的思路
验证用户输入是否正确是我们应用程序中的常见功能。Spring提供了`@Valid`和@`Validated`两个注解来实现验证功能,本文详细介绍 [@Valid]和[@Validated]注解的区别 。
引入pdf2dom &lt;dependency&gt; &lt;groupId&gt;net.sf.cssbox&lt;/groupId&gt; &lt;artifactId&gt;pdf2dom&lt;/artifactId&gt; &lt;version&gt;1.8&lt;/version&
grafana 是一款非常优秀的可视化报表工具,有设计精良的可视化工具,今天来聊一聊如何将grafana集成到自己的应用中。 原理是: grafana允许iframe访问,开启auth.proxy, java 后端鉴权后代理grafana 前端通过iframe访问后端代理过的grafana graf
介绍 Call Graph是一款IDEA插件,用于可视化基于IntelliJ平台的IDE的函数调用图。 这个插件的目标是让代码更容易理解,有助于读懂和调试代码。当前只支持Java。针对Typescript、Javascript或Python工具,可以使用作者的另外一款工具Codemap(https:
原理 通过线程安全findAndModify 实现锁 实现 定义锁存储对象: /** * mongodb 分布式锁 */ @Data @NoArgsConstructor @AllArgsConstructor @Document(collection = &quot;distributed-loc
Singleton 单例模式 单例模式是确保每个应用程序只存在一个实例的机制。默认情况下,Spring将所有bean创建为单例。 你用@Autowired获取的bean,全局唯一。 @RestController public class LibraryController { @Autowired
pipeline 分布式任务调度器 目标: 基于docker的布式任务调度器, 比quartzs,xxl-job 更强大的分布式任务调度器。 可以将要执行的任务打包为docker镜像,或者选择已有镜像,自定义脚本程序,通过pipeline框架来实现调度。 开源地址: https://github.c
python训练的模型,转换为onnx模型后,用python代码可以方便进行推理,但是java代码如何实现呢? 首先ONNX 推理,可以使用`onnxruntime` ```xml com.microsoft.onnxruntime onnxruntime 1.15.1 ``` 另外,训练的模型需要
要获取内网地址,可以尝试连接到10.255.255.255:1。如果连接成功,获取本地套接字的地址信息就是当前的内网IP。 python实现: ```python import socket def extract_ip(): st = socket.socket(socket.AF_INET, s
为什么要有索引 gremlin 其实是一个逐级过滤的运行机制,比如下面的一个简单的gremlin查询语句: g.V().hasLabel(&quot;label&quot;).has(&quot;prop&quot;,&quot;value&quot;) 运行原理就是: 找出所有的顶点V 然后过滤出
最近在分析一个应用中的某个接口的耗时情况时,发现一个看起来极其普通的对象创建操作,竟然每次需要消耗 8ms 左右时间,分析后发现这个对象可以通过对象池模式进行优化,优化后此步耗时仅有 0.01ms。
点赞再看,动力无限。Hello world : ) 微信搜「 程序猿阿朗 」。 本文 Github.com/niumoo/JavaNotes 和 未读代码网站 已经收录,有很多知识点和系列文章。 此篇文章介绍 Java JMX 技术的相关概念和具体的使用方式。 当前文章属于Java 性能分析优化系列
如何将Java JAR 转化为 win/mac/linux 独立可执行程序?不需要预装 JRE 运行?
点赞再看,动力无限。 微信搜「 程序猿阿朗 」。 本文 Github.com/niumoo/JavaNotes 和 未读代码博客 已经收录,有很多知识点和系列文章。 Java 19 在2022 年 9 月 20 日正式发布,Java 19 不是一个长期支持版本,直到 2023 年 3 月它将被 JD
点赞再看,动力无限。Hello world : ) 微信搜「 程序猿阿朗 」。 本文 Github.com/niumoo/JavaNotes 和 未读代码博客 已经收录,有很多知识点和系列文章。 前言 Java 反编译,一听可能觉得高深莫测,其实反编译并不是什么特别高级的操作,Java 对于 Cla
JSON 对于开发者并不陌生,如今的 WEB 服务、移动应用、甚至物联网大多都是以 **JSON** 作为数据交换的格式。学习 JSON 格式的操作工具对开发者来说是必不可少的。这篇文章将介绍如何使用 **Jackson** 开源工具库对 JSON 进行常见操作。