?? courseexcel.java
字號:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: CourseExcel.java
package excel;
import java.io.*;
import java.sql.*;
import jxl.*;
import jxl.read.biff.BiffException;
import mypackage.DataBaseConnection;
public class CourseExcel
implements Serializable
{
private Connection con;
Statement stmt;
ResultSet rst;
String sql;
String str;
Cell cell;
public CourseExcel()
{
con = null;
stmt = null;
rst = null;
sql = "";
str = "";
cell = null;
try
{
con = DataBaseConnection.getConnection();
stmt = con.createStatement(1005, 1008);
}
catch (SQLException sqlexception)
{
System.err.println(sqlexception.getMessage());
}
}
public int addExcel(String s)
{
Workbook workbook;
Sheet sheet;
File file = new File(s);
FileInputStream fileinputstream = new FileInputStream(file);
workbook = Workbook.getWorkbook(fileinputstream);
sheet = workbook.getSheet(0);
if (sheet.getColumns() <= 5)
break MISSING_BLOCK_LABEL_53;
System.out.print("Excel中列數超過了數據庫字段值,操作已中止!");
return 2;
if (sheet.getColumns() >= 5)
break MISSING_BLOCK_LABEL_74;
System.out.print("Excel中列數少于數據庫字段值,操作已中止!");
return 3;
try
{
for (int i = 0; i < sheet.getRows(); i++)
{
for (int j = 0; j < sheet.getColumns(); j++)
{
cell = sheet.getCell(j, i);
if (j != sheet.getColumns() - 1)
str += "'" + cell.getContents() + "',";
else
str += "'" + cell.getContents() + "'";
}
sql = "insert into kecheng values(" + str + ")";
stmt.executeUpdate(sql);
str = "";
}
try
{
stmt.close();
con.close();
workbook.close();
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
catch (IOException ioexception)
{
ioexception.printStackTrace();
return 0;
}
catch (BiffException biffexception)
{
biffexception.printStackTrace();
return 0;
}
catch (SQLException sqlexception)
{
sqlexception.printStackTrace();
return 10;
}
return 1;
}
public int Exist(String s)
{
rst = stmt.executeQuery("select * from kecheng where courseId='" + s + "'");
if (rst.next())
return 1;
break MISSING_BLOCK_LABEL_65;
SQLException sqlexception;
sqlexception;
System.err.println(sqlexception.getMessage());
return 0;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -