test

String driver = "com.mysql.jdbc.Driver";
String dburl = "jdbc:mysql://127.0.0.1:3306/dddddd?characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=convertToNull" ;    
    String username = "root" ;   
    String password = "root" ;   
    Connection conn = null;  
    PreparedStatement ps = null;  
    String sql = "insert into dd() values(?,?,?,?,?,?,?,?)"; 
       try {  
      Class.forName(driver); //classLoader,加载对应驱动
   conn = (Connection) DriverManager.getConnection(dburl, username, password);
           ps = conn.prepareStatement(sql); 
           jxl.Workbook readwb = null;  
           InputStream instream = new FileInputStream("");   
           
           readwb = Workbook.getWorkbook(instream);   
 
           Sheet readsheet = readwb.getSheet(0);   
 
           int rsColumns = readsheet.getColumns();   
           int rsRows = readsheet.getRows();   
           SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
           String date = sdf.format(new Date());
          // int c = 0;
           int c = 215;
           for (int i = 0; i < rsRows; i++)   
           {  
          String timeCode = "";
          Cell cell = readsheet.getCell(1, i);
          Cell message = readsheet.getCell(2, i); 
          String key = cell.getContents();
          if(key.equals("")){
          timeCode = "0"; 
          }else if(key.equals("")){
          timeCode = "1";
          }
          else if(key.equals("")){
          timeCode = "2";
          }
          if(!key.equals("") && !key.equals("")&&!key.equals("")){
          key = "";
          timeCode = "";
          }
               if(!message.getContents().equals("")){
              c++;
        String no = "";
        if(c<10){
        no = "m000"+c;
        }else if(c<100){
        no = "m00"+c;
        }else if(c <1000){
        no = "m0"+c;
        }else if(c < 10000){
        no = "m"+c;
        }
                   ps.setString(1, no);
                   ps.setString(2,timeCode);  
                   ps.setString(3, key);
                   ps.setString(4, message.getContents());
                   ps.setString(5, date);
                   ps.setString(6, "admin");
                   ps.setString(7, "");
                   ps.setString(8, "0");
              ps.addBatch();
                   ps.executeBatch();  
               }
           }   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值