Java ´ÓExcelÎļþ»ñÈ¡µÄÊý¾Ý ÈçºÎ²åÈëµ½mysqlÖÐÈ¥
1.ExcelÎļþ»ñÈ¡µ½µÄÊý¾Ý ÀýÈçÏÂÃæµÄ£º
ÐòºÅ Óû§ÐÕÃû ÁªÏµµç»° µØÖ· ²úÆ·ÐͺÅ
1 ÕÅÈý 11111111 ¸»Àö7-1-201 5 YT
2 ÀîËÄ 22222222 ÃÀµØÍå¾°7-2-301 YF
2.ÈçºÎ½«ÕâЩÊý¾Ý·â×°³ÉList °ÑËü×÷Ϊwrite·½·¨µÄ²ÎÊý´«½ø
public int write(List list) throws SQLException {
Connection con = null;
PreparedStatement ps = null;
int i = 0;
try {
//1 ¼ÓÔØclass
Class.forName(CConnectInfo.driver);
//2 ´´½¨Á¬½Ó
con = DriverManager.getConnection(CConnectInfo.url,CConnectInfo.username,CConnectInfo.password);
String sql = "insert into consumer(name,cellPhone1,address,productId) values(?,?,?,?,?,?,?)";//?ºÅÊÇռλ·û£¬Ï£Íû¶¯Ì¬¸³ÖµµÄ;
//3 ´´½¨preparedStatement¶ÔÏó
ps = con.prepareStatement(sql);
//4 Ϊps¸³Öµ
ÕâÀï¸ÃÈçºÎд£¿
i = ps.executeUpdate();
}catch(ClassNotFoundException e) {
e.printStackTrace();
}finally {
if(con != null)
con.close();
con = null;
if(ps != null)
ps.close();
ÎÒÒÔǰ°²×°ÁËÒ»´Î£¬ºóÀ´Ð¶ÔØÁË£¬ÏÖÔÚÔÙ°²×°µÄʱºò£¬Ìáʾ´íÎó£ºError 1305.Error reading from file C:DOCUME~1\LOCALS~1\Temp\mysql_server.msi.Verify that the file exists and that you can access it.
¿ ......
ÔÚ°²×°Java±àÒëÆ÷µÄEclipseµÄʱºò£¬¶Ô»·¾³±äÁ¿½øÐÐÁËÅäÖã¬ÔÚ°²×°MySQlµÄʱºòÒ²Òª¶Ô»·¾³±äÁ¿½øÐÐÅäÖã»ÄÇôºóÃæµÄÅäÖûáÓ°ÏìÇ°ÃæµÄEclipseµÄÅäÖÃÂð£¿
Çë´ó¼Ò¶àÖ¸½Ì~£¡Ð»Ð»£¡
²»»á°Ñ£¬ÎÒÕâ¶¼×°Á赀 ÎÒϵͳÀï »¹×°ÁË ......