資源描述:
《excel導(dǎo)入數(shù)據(jù)庫及反向?qū)С觥酚蓵T上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、EXCEL導(dǎo)入數(shù)據(jù)庫及數(shù)據(jù)庫數(shù)據(jù)導(dǎo)出到EXCEL關(guān)鍵字:報表、jel??很久沒有發(fā)BLOG,呵呵,是因為最近在幫助朋友在做一個項目,很忙。呵呵,我覺得生活就應(yīng)該是這樣,年輕時候的忙碌是為年老時候的悠閑吧。??主要涉及內(nèi)容及技術(shù):?javaexcelapi?jasonreport及編輯工具ireport和數(shù)據(jù)庫技術(shù)。?導(dǎo)入及導(dǎo)出EXCEL解決思路:?使用javaexcelapi導(dǎo)入普通的EXCEL表格,就是沒有合并單元格的規(guī)范數(shù)據(jù),如果導(dǎo)出有規(guī)則的EXCEL也使用JAVAEXECELAPI,對中文支持
2、比較好。?如果要導(dǎo)出報表可打印的EXCEL,使用ireport為工具圖形化畫出報表,并使用jasonreprt控制導(dǎo)出,展示給客戶端。?主要代碼有:?連接數(shù)據(jù)庫的方法:java代碼?1.import?java.sql.Connection;??2.import?java.sql.ResultSet;??3.import?java.sql.SQLException;??4.import?java.sql.Statement;??5.import?java.util.Hashtable;??6.impo
3、rt?java.util.Vector;??7.import?org.apache.log4j.Logger;??8.public?class?DBOperate?{?????9.??????10.????/**?11.?????*?得到sequence的nextval?12.?????*?@param?sequenceName??13.?????*?@return?14.?????*/??15.????public?static?String?getSequence(String?sequence
4、Name)?{??16.????????String?nextval?=?"";??17.????????if(sequenceName?==?null?
5、
6、?"".equals(sequenceName))?{??18.????????????System.out.println("sequenceName?name?is?null!");?????????????19.????????????return?null;??20.????????}?else?{??21.????????????se
7、quenceName?=?sequenceName.toUpperCase();????????????1.????????????String?sql?=?"select?"?+?sequenceName?+?".nextval?nextid?from?user_sequences?where?sequence_name?=?'"???2.???????????????????????+?sequenceName?+?"'";??3.??????????????4.????????????Stat
8、ement?stmt?=?null;??5.????????????Connection?conn?=?null;??6.????????????ResultSet?rs?=?null;??7.??????????????8.????????????try?{??9.????????????????conn?=?TreatDB.getConnDB("");??10.????????????????if?(conn?!=?null)?{??11.????????????????????stmt?=?c
9、onn.createStatement();??12.????????????????????rs?=?stmt.executeQuery(sql);??13.??????????????????????14.????????????????????if(rs?!=?null)?{??15.??????????????????????while(rs.next())?{??16.????????????????????????nextval?=?rs.getString("nextid");????
10、?????????????????????17.??????????????????????}??18.????????????????????}??19.????????????????}??20.????????????}?catch?(SQLException?e)?{??21.????????????????System.out.println("SQLException?:?"?+?e);??22.????????????}?finally?{??23.??