⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 courseexcel.java

📁 JSP开发的学生信息管理系统
💻 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 + -