⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addbooks.java~9~

📁 这是一个用jbuilder2005编写的图书管理系统
💻 JAVA~9~
字号:
package bookmanage;

import javax.swing.*;
import java.io.*;
import java.sql.*;

/**
 * <p>Title: 图书管理系统</p>
 *
 * <p>Description: 此类是用来批量增加图书</p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: 浙江工业大学信息学院计算机系</p>
 *
 * @author 曾文秋
 * @version 1.0
 */
public class AddBooks {
  File fOpen=null;
  DBManager db=new DBManager();
  ResultSet rs;
  public AddBooks(){
    JFileChooser fileSelection=new JFileChooser();
    File dir=new File("./");
    fileSelection.setApproveButtonText("确定");
    fileSelection.setCurrentDirectory(dir);
    fileSelection.addChoosableFileFilter(new Filter("xls"));
    int index=fileSelection.showOpenDialog(null);
    if(index==fileSelection.CANCEL_OPTION)
      return;
    fOpen=fileSelection.getSelectedFile();
    String strSql;
    String yinghao = "\"";
    //String maohao="\\";
    strSql="select * from  OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source="+
        yinghao+fOpen.getAbsolutePath()+yinghao+";Extended Properties="+yinghao+
        "Excel 5.0"+yinghao+";Persist Security Info=False')...books";
    System.out.println(strSql);

    rs=db.getResult(strSql);
    boolean isexist=false;
    try{
        isexist=rs.first();
    }catch(SQLException e1){}
    if(!isexist)
    {
        JOptionPane.showMessageDialog(null,"该表没有要倒入的内容 ");
        return;
    }
    else{
      try{
        rs.beforeFirst();
        while(rs.next()){
          String strName,strIsbn,strAuthor,strPublisher,strPubDate,strGuanjianzi,strAdress;
          float fPrice;
          int num;
          strName=rs.getString(1);
          strIsbn=rs.getString(2);
          strAuthor=rs.getString(3);
          fPrice=Float.parseFloat(rs.getString(4));
          strPublisher=rs.getString(5);
          strPubDate=rs.getString(6);
          strGuanjianzi=rs.getString(7);
          strAdress=rs.getString(8);
          num=Integer.parseInt(rs.getString(9));
          strSql="exec Pro_InsertBook '"+strName+"','"+strIsbn+"','"+strAuthor+"',"+
          ""+fPrice+",'"+strPublisher+"','"+strPubDate+"','"+strGuanjianzi+"','"+strAdress+"',"+num+"";
          db.executeSql(strSql);
        }
      }catch(SQLException e){
        e.printStackTrace();
      }

    }
    db.close();

  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -