jlr提交
This commit is contained in:
101
src/main/java/com/ljh/excel/test/MySqlTest.java
Normal file
101
src/main/java/com/ljh/excel/test/MySqlTest.java
Normal file
@ -0,0 +1,101 @@
|
||||
package com.ljh.excel.test;
|
||||
|
||||
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import com.ljh.excel.bean.factory.ExcelFactory;
|
||||
|
||||
public class MySqlTest {
|
||||
public static void main(String[] args) throws SQLException {
|
||||
ExcelFactory.PACTORYPATH="F:\\vmx";
|
||||
List list=new ArrayList();
|
||||
list.add(new User());
|
||||
list.add(new User("ljh2","test","test"));
|
||||
list.add(new User("ljh3","test","test"));
|
||||
new User().saveAll(list,"F:\\text.xlsx");
|
||||
// Connection conn = null;
|
||||
// PreparedStatement stmt = null;
|
||||
// ResultSet rs = null;
|
||||
//
|
||||
// try {
|
||||
// Class.forName("com.mysql.jdbc.Driver");
|
||||
// conn = DriverManager.getConnection(
|
||||
// "jdbc:mysql://localhost:3306/jeecp", "root",
|
||||
// "");
|
||||
// stmt = conn.prepareStatement("select * from person where id=?");
|
||||
// stmt.setInt(1, 10);
|
||||
// rs = stmt.executeQuery();
|
||||
// while (rs.next()) {
|
||||
// System.out.println(rs.getInt("id"));
|
||||
// System.out.println(rs.getString("name"));
|
||||
// System.out.println("----------------------------");
|
||||
// }
|
||||
// } catch (ClassNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (SQLException e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// if (rs != null)
|
||||
// rs.close();
|
||||
// if (stmt != null)
|
||||
// stmt.close();
|
||||
// if (conn != null)
|
||||
// conn.close();
|
||||
// }
|
||||
// Integer i1=new Integer("2");
|
||||
// Integer i2=new Integer("2");
|
||||
// System.out.println((int)i1==(int)i2);
|
||||
// try {
|
||||
//// List<ETabDispatch> datalist2 = new ETabDispatch().selectAll("C:/Users/junhui/Desktop/tes.xlsx");
|
||||
//// for(ETabDispatch ed:datalist2){
|
||||
//// System.out.println("ed:"+ed);
|
||||
//// }
|
||||
//// System.out.println("datalist2:"+datalist2.size());
|
||||
// ExcelFactory.instance("d://");
|
||||
// SevenParams p1=new SevenParams("SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams");
|
||||
// SevenParams p2=new SevenParams("SevenParams", "SevenParams", "SevenParams");
|
||||
// SevenParams p3=new SevenParams("SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams");
|
||||
// SevenParams p4=new SevenParams("SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams", "SevenParams");
|
||||
// List list=new ArrayList<>();
|
||||
// list.add(p1);
|
||||
// list.add(p2);
|
||||
// list.add(p3);
|
||||
// list.add(p4);
|
||||
//
|
||||
// p1.saveAll(list,"d://SevenParams.xlsx");
|
||||
// } catch (Exception e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// System.out.println("days:"+daysBetween("2016-10-13 12:44:31","2016-10-15 12:44:31"));
|
||||
}
|
||||
/**
|
||||
*字符串的日期格式的计算
|
||||
*/
|
||||
public static int daysBetween(String smdate,String bdate){
|
||||
try {
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(sdf.parse(smdate));
|
||||
long time1 = cal.getTimeInMillis();
|
||||
cal.setTime(sdf.parse(bdate));
|
||||
long time2 = cal.getTimeInMillis();
|
||||
long between_days=(time2-time1)/(1000*3600*24);
|
||||
|
||||
return Integer.parseInt(String.valueOf(between_days));
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user