java的poi技术读取Excel数据到MySQL
发布时间:2020-12-14 06:30:36 所属栏目:Java 来源:网络整理
导读:这篇blog是介绍java中的poi技术读取Excel数据,然后保存到MySQL数据中。 你也可以在 : ? 了解到写入Excel的方法信息 使用JXL技术可以在 : `id` ( ) `no` ( ) `name` ( ) `age` ( ) `score` ) ENGINE InnoDB CHARSET utf8; main(String[] args) SaveData2DB
这篇blog是介绍java中的poi技术读取Excel数据,然后保存到MySQL数据中。 你也可以在 :?了解到写入Excel的方法信息 使用JXL技术可以在 :
`id` () `no` () `name` () `age` () `score` ) ENGINEInnoDB CHARSETutf8;
main(String[] args) SaveData2DB saveData2DB = System.out.println("end" }
String DRIVER = "com.mysql.jdbc.Driver" String DB_NAME = "test" String USERNAME = "root" String PASSWORD = "root" String IP = "192.168.1.103" String PORT = "3306" String URL = "jdbc:mysql://" + IP + ":" + PORT + "/" +
String EXCEL_PATH = "lib/student_info.xls"
String INSERT_STUDENT_SQL = "insert into student_info(no,name,age,score) values(?,?,?)" String UPDATE_STUDENT_SQL = "update student_info set no = ?,name = ?,age= ?,score = ? where id = ? " String SELECT_STUDENT_ALL_SQL = "select id,no,score from student_info" String SELECT_STUDENT_SQL = "select * from student_info where name like " }
List
@SuppressWarnings({ "rawtypes" save() ReadExcel xlsMain = Student student = List
insert(String sql,Student student) Connection conn = PreparedStatement ps = conn = ps = ps.setString(1 ps.setString(2 ps.setString(3 ps.setString(4 flag = (! System.out.println("Save data : No. = " + student.getNo() + ",Age = " + student.getAge() + " succeed!" } } (ps != (conn !=
@SuppressWarnings({ "unchecked","rawtypes" List selectOne(String sql,Student student) Connection conn = PreparedStatement ps = ResultSet rs = List list = conn = ps = rs = (rs.getString("no").equals(student.getNo()) || rs.getString("name").equals(student.getName())|| rs.getString("age" list.add(1 } list.add(0 } } (rs != (ps != (conn !=
ResultSet selectAll(String sql) Connection conn = PreparedStatement ps = ResultSet rs = conn = ps = rs = } |