import java.io.FileInputStream;
import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import org.apache.poi.hssf.urmodel.HSSFRow;
import org.apache.poi.hssf.urmodel.HSSFSheet;
文科二本大学分数线import org.apache.poi.hssf.urmodel.HSSFWorkbook;
import org.apache.poi.xssf.urmodel.XSSFRow;
import org.apache.poi.xssf.urmodel.XSSFSheet;
import org.apache.poi.xssf.urmodel.XSSFWorkbook;
import com.longri.LEAP.Ba.Global;
public class InrtExcel {
public static void readExcel2003(String fileName) {
Connection conn= null;
Statement stmt = null;
CallableStatement cs = null;
try {
展台英文
String inrtSql = "";
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@192.168.137.46:1521:leap"; //orcl为数据库的SID
String ur="dbo";
String password="longri";
conn= Connection(url,ur,password);
stmt = ateStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
//ResultSet rs = uteQuery("lect * from EXCELDATA");
//rs.last();
//System.out.println("^^"+rs.getRow());
HSSFSheet sheet = null;
// 定义 row、cell
HSSFRow row = null;
// HSSFCell cell;
String cell = null;
HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(fileName));
// 读取文件中的第一张表格
int sheetNum = wb.getSelectedTab()+1;
System.out.println("num**"+sheetNum);
for(int ii=0; ii<sheetNum; ii++){
sheet = wb.getSheetAt(ii);
fragment // 循环输出表格中的内容
for (int i = FirstRowNum(); i < PhysicalNumberOfRows(); i++) {
inrtSql = "inrt into EXCELDATA(name,md1,md2,md3,id) values ('owner','";
row = Row(i);
for (int j = FirstCellNum(); j < PhysicalNumberOfCells(); j++) {
// 推荐通过 Cell(j).toString() 获取单元格内容,
Cell(j) != null){
cell = Cell(j).toString();
温床 if(j==1 || j==2){
inrtSql = inrtSql+cell+"','";
}el if(j==3){
inrtSql = inrtSql+cell+"',";
}
}
}
inrtSql = inrtSql+"sys_guid())";
System.out.println("sql&&"+inrtSql);
ute(inrtSql);
}
}
String sql = "{call UPDATEexceldata()}";
cs = conn.prepareCall(sql);
cs.execute();
} catch (Exception e) {
System.out.println(e);
}finally{
if(conn != null){
try {
cs.clo();
夹克衫的英文 stmt.clo();
conn.clo();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
public static void readExcel2007(String fileName) {
try {
XSSFWorkbook xwb = new XSSFWor
kbook(fileName);
hitchcock // 读取第一章表格内容
XSSFSheet sheet = SheetAt(0);
// 定义 row、cell
XSSFRow row;
String cell;
// 循环输出表格中的内容
for (int i = FirstRowNum(); i < PhysicalNumberOfRows(); i++) {
row = Row(i);
for (int j = FirstCellNum(); j < PhysicalNumberOfCells(); j++) {
// 通过 Cell(j).toString() 获取单元格内容,
cell = Cell(j).toString();
System.out.print(cell + "\t");
} full test
System.out.println("");
}
} catch (Exception e) {
custody System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss:SS");
TimeZone t = TimeZone();
t.tRawOfft(0);
sdf.tTimeZone(t);
Long startTime = System.currentTimeMillis();
//String fileName2007 = "F:\\sad.xls";大望路地铁站
String fileName2003 = "F:\\df\\2.xls";//路径
// 检测代码
实现梦想英文 try {
// 读取excel2007
//readExcel2007(fileName2007);
// 读取excel2003
readExcel2003(fileName2003);
} catch (Exception e) {
System.out.println(e);
}
Long endTime = System.currentTimeMillis();
System.out.println("用时:" + sdf.format(new Date(endTime - startTime)));
}
}