1 package poi;
2 import java.io.FileInputStream;
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.util.Iterator;
6 import org.apache.poi.hssf.usermodel.HSSFCell;
7 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
8 import org.apache.poi.ss.usermodel.Cell;
9 import org.apache.poi.ss.usermodel.Row;
10 import org.apache.poi.ss.usermodel.Sheet;
11 import org.apache.poi.ss.usermodel.Workbook;
12 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
13
14 public class ReadExcel001 {
15 public static void main(String[] args) {
16 readXml("D:/test.xlsx");
17 System.out.println("-------------");
18 readXml("d:/test2.xls");
19 }
20 public static void readXml(String fileName){
21 boolean isE2007 = false; //判断是否是excel2007格式
22 if(fileName.endsWith("xlsx"))
23 isE2007 = true;
24 try {
25 InputStream input = new FileInputStream(fileName); //建立输入流
26 Workbook wb = null;
27 //根据文件格式(2003或者2007)来初始化
28 if(isE2007)
29 wb = new XSSFWorkbook(input);
30 else
31 wb = new HSSFWorkbook(input);
32 Sheet sheet = wb.getSheetAt(0); //获得第一个表单
33 Iterator<Row> rows = sheet.rowIterator(); //获得第一个表单的迭代器
34 while (rows.hasNext()) {
35 Row row = rows.next(); //获得行数据
36 System.out.println("Row #" + row.getRowNum()); //获得行号从0开始
37 Iterator<Cell> cells = row.cellIterator(); //获得第一行的迭代器
38 while (cells.hasNext()) {
39 Cell cell = cells.next();
40 System.out.println("Cell #" + cell.getColumnIndex());
41 switch (cell.getCellType()) { //根据cell中的类型来输出数据
42 case HSSFCell.CELL_TYPE_NUMERIC:
43 System.out.println(cell.getNumericCellValue());
44 break;
45 case HSSFCell.CELL_TYPE_STRING:
46 System.out.println(cell.getStringCellValue());
47 break;
48 case HSSFCell.CELL_TYPE_BOOLEAN:
49 System.out.println(cell.getBooleanCellValue());
50 break;
51 case HSSFCell.CELL_TYPE_FORMULA:
52 System.out.println(cell.getCellFormula());
53 break;
54 default:
55 System.out.println("unsuported sell type");
56 break;
57 }
58 }
59 }
60 } catch (IOException ex) {
61 ex.printStackTrace();
62 }
63 }
64 }
tomcat如果是通过windows服务启动,执行的是bin\tomcat.exe.他读取注册表中的值,而不是catalina.bat的设置.解决办法:修改注册表HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\Tomcat6\Parameters\JavaOptions原值为-Dcatalina.home=E:\Tomcat 6.0-Dcatalina.base=E:\Tomcat 6.0-Djava.endorsed.dirs=E:\Tomcat 6.0\common\endorsed-Djava.io.tmpdir=E:\Tomcat 6.0\temp-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager-Djava.util.logging.config.file=E:\Tomcat 6.0\conf\logging.properties
在后面增加即可:
-Xms128M
-Xmx512M
-XX:PermSize=128M
-XX:MaxPermSize=512M
必须要分行写。
最终效果如下:
当一个数据库的数据文件达到表空间的最大值时,报ORA-1653:的错误。如下:
ORA-1653: unable to extend table TEST.COMM_DTTR_SVR_LOG by64 in tablespace TEST_SPACE
解决:
可以在该表空间中增加一个数据文件,增加的数据文件为自动扩展,无限扩大。
查看数据文件的大小和最大的值,可以查询dba_data_files;
Sql>
alter tablespace TEST_SPACE
adddatafile'/Oracle/oms/oradata/pub/Norm_data001.dbf'
size 10M autoextend on MAXSIZE UNLIMITED;
或者把该表空间所在的数据文件设置成自动扩张,设置该maxsize更大,unlimited表示没有限制。
SQL>
alter database
datafile '/oracle/oms/oradata/pub/Pub_Norm_data001.dbf'
autoextend on maxsize unlimited;
共计以下4个文件 点击“下载”
login.html
welcome.html
cookie.js
common.js
login.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>login</title>
<script type="text/javascript" src="cookie.js"></script>
<script type="text/javascript" src="common.js"></script>
</head>
<body>
<form action="">
<p>
<span>UserName:</span>
<input id="userName" type="text" value=""/></p>
<p>
<span>Password:</span>
<input id="password" type="password" value=""/></p>
<p>
<span style="font-size:12px; color:blue;">记住密码</span>
<input id="saveCookie" type="checkbox" value="" /></p>
<p>
<input id="submit" type="button" value="GO" />
</p>
</form>
</body>
</html>
welcome.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>welcome</title>
</head>
<body>
<h1>Welcome!</h1>
<a href="login.html">点击返回登陆框</a>
</body>
</html>
cookie.js
//新建cookie。
//hours为空字符串时,cookie的生存期至浏览器会话结束。hours为数字0时,建立的是一个失效的cookie,这个cookie会覆盖已经建立过的同名、同path的cookie(如果这个cookie存在)。
function setCookie(name,value,hours,path){
var name = escape(name);
var value = escape(value);
var expires = new Date();
expires.setTime(expires.getTime() + hours*3600000);
path = path == "" ? "" : ";path=" + path;
_expires = (typeof hours) == "string" ? "" : ";expires=" + expires.toUTCString();
document.cookie = name + "=" + value + _expires + path;
}
//获取cookie值
function getCookieValue(name){
var name = escape(name);
//读cookie属性,这将返回文档的所有cookie
var allcookies = document.cookie;
//查找名为name的cookie的开始位置
name += "=";
var pos = allcookies.indexOf(name);
//如果找到了具有该名字的cookie,那么提取并使用它的值
if (pos != -1){ //如果pos值为-1则说明搜索"version="失败
var start = pos + name.length; //cookie值开始的位置
var end = allcookies.indexOf(";",start); //从cookie值开始的位置起搜索第一个";"的位置,即cookie值结尾的位置
if (end == -1) end = allcookies.length; //如果end值为-1说明cookie列表里只有一个cookie
var value = allcookies.substring(start,end); //提取cookie的值
return (value); //对它解码
}
else return ""; //搜索失败,返回空字符串
}
//删除cookie
function deleteCookie(name,path){
var name = escape(name);
var expires = new Date(0);
path = path == "" ? "" : ";path=" + path;
document.cookie = name + "="+ ";expires=" + expires.toUTCString() + path;
}
common.js
function $(objStr){return document.getElementById(objStr);}
window.onload = function(){
//分析cookie值,显示上次的登陆信息
var userNameValue = getCookieValue("userName");
$("userName").value = userNameValue;
var passwordValue = getCookieValue("password");
$("password").value = passwordValue;
//写入点击事件
$("submit").onclick = function()
{
var userNameValue = $("userName").value;
var passwordValue = $("password").value;
//服务器验证(模拟)
var isAdmin = userNameValue == "admin" && passwordValue =="123456";
var isUserA = userNameValue == "userA" && passwordValue =="userA";
var isMatched = isAdmin || isUserA;
if(isMatched){
if( $("saveCookie").checked){
setCookie("userName",$("userName").value,24,"/");
setCookie("password",$("password").value,24,"/");
}
alert("登陆成功,欢迎你," + userNameValue + "!");
self.location.replace("welcome.html");
}
else alert("用户名或密码错误,请重新输入!");
}
}