| 內容 |
|
|
viva wrote:不好意思,在請教一下
ftp.setDefaultPort(21);
這語法的用意是什麼?為何會設21與13?
若不加這行,也OK嗎?
因為FTP通訊協定預設的通訊埠是21,而org.apache.commons.net.ftp.FTP.DEFAULT_PORT的值即為21,所以如果您要連的FTP Server沒有改過port號的話,不用加這一行也OK。
另外,我的範例程式中應該是沒加這一行,也沒看到什麼13的數字,所以我無法回答「為何會設21與13?」
|
 |
|
|
SQL Server 2005 Express的SQL Server Management Studio Express沒有提供匯入/匯出精靈,只有在花錢買的版本才有提供,若要從Excel匯入資料只能從SQL查詢視窗使用SQL指令匯入,但要使用SQL指令匯入需要先開啟OPENROWSET才能執行匯入功能。
依序操作如下:
Microsoft SQL Server 2005 > 組態工具 > SQL Server 2005 介面組態 > 功能的介面區組態 > 勾選「啟用OPENROWSET和OPENDATASOURCE支援」
將要匯入的Excel檔就定位,例如放在D:\testdata\zipcode.xls,檢查一下,第一行是欄位名稱,第二行起是資料的部分,然後工作表名稱可以維持原本的Sheet1或是自己重新命名(記得下面的Sheet1$要配合修改)
接著就可以執行
SELECT * INTO zone FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D:\testdata\zipcode.xls', [Sheet1$])
http://sunrise-msn.spaces.live.com/blog/cns!487A9984929026B7!392.entry
http://support.microsoft.com/kb/321686
http://forums.microsoft.com/Technet-CHT/ShowPost.aspx?PostID=3697780&SiteID=23
|
 |
|
|
等了好久,從8/13發現 http://www.certmanager.net/sun顯示為Mailed到今天(8/26)終於證書寄到了,跟先前大家說的一樣,用一個牛皮紙袋裝著,然後用片厚紙板當底,附上兩張恭賀信及證書一張,還有一張跟信用卡一樣大小可以隨身攜帶的證明卡及一個小胸章。
信上寫著可以到 http://logos.sun.com/logosite.jsp?Category=third&Logo=java-cert-prog&Page=requestclick這邊申請Logo,稍微看了一下 使用授權,大致上就是說盡量不要讓這個Logo在名片上顯得太大即可。
|
 |
|
|
viva wrote:不好意思請問一下
ftptest.jsp裡有這一行 ftp.setDefaultTimeout(30000);
設定這時間是什麼意思?
原來的程式碼上寫了:
// We want to timeout if a response takes longer than 30 seconds
ftp.setDefaultTimeout(30000);
因為setDefaultTimeout(int timeout)裡面timeout的單位是milliseconds(千分之一秒),故我們要乘上1000,就變成30000。
至於為何要設定Timeout,是因為在建立TCP的socket連線時,需要等候連線的對方回應ACK,以確認對方還活著,而這個等候的時間就是Timeout的時間,超過這個時間,我們就認為對方掛了,這個connection就無法成功建立。
|
 |
|
|
這個週末花了兩天終於把現有的OLAT由5.2.3升級至6.0.0, 步驟如下:
cd ~/download
mv olat3 olat-5.2.3
wget http://www.olat.org/downloads/stable/OLAT-6.0.0.zip
unzip OLAT-6.0.0.zip
mv OLAT-6.0.0-PUBLIC-* olat3
cd olat3
sed -e "s/\/usr\/local\/opt\/olat\/olat3/\/home\/andowson\/download\/olat3/g" \
-e "s/\/usr\/local\/opt\/olat\/olatdata/\/home\/andowson\/www\/data\/olatdata/g" \
-e "1,$$s/myolat/andowson/g" \
-e "s/smtp.host=smtp.andowson.com/smtp.host=mail.andowson.com/" \
-e "s/\/usr\/local\/opt\/tomcat/\/var\/tomcat5/g" \
-e "1,$$s/net.sf.hibernate/org.hibernate/g" \
-e "48c\server.modjk.enabled=true" \
-e "95,117d" \
-e "1,$$s/#db/db/g" \
-e "s/instantMessaging.enable=false/instantMessaging.enable=true/" \
-e "s/instantMessaging.server.name=jabber.andowson.com/instantMessaging.server.name=www.andowson.com/" \
-e "s/instantMessaging.generateTestUsers=false/instantMessaging.generateTestUsers=true/" \
-e "s/instantMessaging.db.name=wildfire/instantMessaging.db.name=openfire/" \
-e "s/instantMessaging.db.user=wildfire/instantMessaging.db.user=olat/" \
-e "s/instantMessaging.db.pass=wildfire/instantMessaging.db.pass=olat/" build.properties.default > build.properties
ant install
ant jsmath
sudo /etc/init.d/tomcat stop
mv ~/www/olat /tmp/olat-5.2.3
cp -rf ~/download/olat3/webapp ~/www/olat
cp -rf ~/download/olat3/htdocs/* ~/www/olat
sed -i -e "13c\ <\!-- default session timeout -->" ~/www/olat/WEB-INF/web.xml
rm -rf ~/www/olat/WEB-INF/src
rm -rf ~/www/olat/WEB-INF/patchesSrc
rm -rf ~/www/olat/WEB-INF/test
cp /tmp/olat-5.2.3/WEB-INF/classes/hibernate.properties ~/www/olat/WEB-INF/classes/.
chgrp -R tomcat ~/www/olat
chgrp -R tomcat ~/www/data/olatdata
chmod 775 ~/www/olat/static
sudo -u postgres pg_dump olat > /tmp/olat.bak
sudo psql -U olat olat -f /home/andowson/download/olat3/database/postgresql/alter_5_2_x_to_6_0_0.sql
sudo /etc/init.d/tomcat start
要注意的地方是原始碼內附的PostgreSQL升級SQL script有問題,字串應該用單引號來括起來,而不是用雙引號,另外有些欄位名稱也不對,必須調整後才能正常執行。好在我有先執行資料庫備份,再執行那條upgrade的SQL,不然這個SQL script只能執行一次,並且會把o_user裡面的一些欄位drop掉(這樣子你連執行第二次的機會都沒有了)。所以記住:要做任何系統升級之前,備份!備份!備份!
以下是我修改後的alter_5_2_x_to_6_0_0.sql:
--
-- new talbe to store the users properties
create table o_userproperty (
fk_user_id int8 not null,
propname varchar(255) not null,
propvalue varchar(255),
primary key (fk_user_id, propname)
);
create index propvalue_idx on o_userproperty (propvalue);
alter table o_userproperty add constraint FK4B04D83FD1A80C95 foreign key (fk_user_id) references o_user;
--
-- migrate data from old user table to new userproperty table
-- make sure you get this right the first time, you can not run this twice!
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'firstName', firstname from o_user where firstname IS NOT NULL AND firstname!='';
alter table o_user drop firstname;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'lastName', lastname from o_user where lastname IS NOT NULL AND lastname!='';
alter table o_user drop lastname;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'email', email from o_user where email IS NOT NULL AND email!='';
alter table o_user drop email;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'birthDay', birthday from o_user where birthday IS NOT NULL;
alter table o_user drop birthday;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'gender', gender from o_user where gender IS NOT NULL AND gender!='';
alter table o_user drop gender;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'telMobile', telmobile from o_user where telmobile IS NOT NULL AND telmobile!='';
alter table o_user drop telmobile;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'telOffice', teloffice from o_user where teloffice IS NOT NULL AND teloffice!='';
alter table o_user drop teloffice;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'telPrivate', telprivate from o_user where telprivate IS NOT NULL AND telprivate!='';
alter table o_user drop telprivate;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'institutionalUserIdentifier', institutionaluseridentifier from o_user where institutionaluseridentifier IS NOT NULL AND institutionaluseridentifier!='';
alter table o_user drop institutionaluseridentifier;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'institutionalName', institutionalname from o_user where institutionalname IS NOT NULL AND institutionalname!='';
alter table o_user drop institutionalname;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'institutionalEmail', institutionalemail from o_user where institutionalemail IS NOT NULL AND institutionalemail!='';
alter table o_user drop institutionalemail;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'street', street from o_user where street IS NOT NULL AND street!='';
alter table o_user drop street;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'extendedAddress', extendedaddress from o_user where extendedaddress IS NOT NULL AND extendedaddress!='';
alter table o_user drop extendedaddress;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'poBox', pobox from o_user where pobox IS NOT NULL AND pobox!='';
alter table o_user drop pobox;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'zipCode', zipcode from o_user where zipcode IS NOT NULL AND zipcode!='';
alter table o_user drop zipcode;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'region', region from o_user where region IS NOT NULL AND region!='';
alter table o_user drop region;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'city', city from o_user where city IS NOT NULL AND city!='';
alter table o_user drop city;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'country', country from o_user where country IS NOT NULL AND country!='';
alter table o_user drop country;
--
-- end user properties migration
-- new table to store the read messages, migrate the read messages from the o_property to the new table
create table o_readmessage (
id int8 not null,
lastmodified timestamp not null,
creationdate timestamp,
identity_id int8 not null,
forum_id int8 not null,
message_id int8 not null,
primary key (id));
create index identity_forum_idx on o_readmessage(identity_id, forum_id);
insert into o_readmessage (id, lastmodified, creationdate, identity_id, forum_id, message_id) select id, lastmodified, creationdate, identity, resourcetypeid, longvalue from o_property where category='rvst';
delete from o_property where category='rvst';
-- end read messages
-- update fontsize to new relative style
update o_user set fontsize = '110' where fontsize = 'large';
update o_user set fontsize = '100' where fontsize = 'normal';
update o_user set fontsize = '90' where fontsize = 'small';
-- end fontsize update
|
 |
|
|
Java內建支援ZIP格式檔案的壓縮及解壓縮,透過使用 java.util.zip套件,我們可以用來將網頁上傳的ZIP檔案加以解壓縮再做後續處理。這裡我們可以先將解壓縮的固定步驟寫成一個UnZipBean,後續要解壓縮zip時只要先將檔名及解壓縮的目錄傳進去,再呼叫unzip()函式即可。
程式碼:
UnZipBean.java:
/*
* Copyright (c) 2005, Andowson Chang
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the "Andowson Chang" nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* This file creation date: 2005/01/31 18:33:36
* Reference:
* http://www.wakhok.ac.jp/~tatsuo/sen97/10shuu/UnZip.java.html
*/
package com.andowson;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
public class UnZipBean {
public static final int EOF = -1;
static final int BUFFER = 2048;
private String zipFile;
private String targetDirectory;
private ZipFile zf;
/** Constructor */
public UnZipBean() {
}
public UnZipBean(String zipFile, String targetDirectory) {
this.zipFile = zipFile;
this.targetDirectory = targetDirectory;
}
public void setZipFile(String zipFile) {
this.zipFile = zipFile;
}
public String getZipFile() {
return zipFile;
}
public void setTargetDirectory(String targetDirectory) {
this.targetDirectory = targetDirectory;
}
public String getTargetDirectory() {
return targetDirectory;
}
public boolean unzip() {
boolean done = false;
if (zipFile != null) {
try {
zf = new ZipFile(zipFile);
Enumeration enumeration = zf.entries();
while (enumeration.hasMoreElements()) {
ZipEntry target = (ZipEntry)enumeration.nextElement();
System.out.print(target.getName() + " .");
saveEntry(target);
System.out.println(". unpacked");
}
done = true;
}
catch (FileNotFoundException e){
System.out.println("zipfile not found"+e.getMessage());
}
catch (ZipException e){
System.out.println("zip error..."+e.getMessage());
}
catch (IOException e){
System.out.println("IO error..."+e.getMessage());
}
finally {
try {
zf.close();
} catch (IOException e) {
System.out.println("IO error...Can't close zip file"+e.getMessage());
}
}
}
return done;
}
private void saveEntry(ZipEntry target)
throws ZipException, IOException {
try {
File file = new File(targetDirectory + File.separator + target.getName());
if (target.isDirectory()) {
file.mkdirs();
}
else {
InputStream is = zf.getInputStream(target);
BufferedInputStream bis = new BufferedInputStream(is);
File dir = new File(file.getParent());
dir.mkdirs();
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
int c;
byte[] data = new byte[BUFFER];
while((c = bis.read(data, 0, BUFFER)) != EOF) {
bos.write(data, 0, c);
}
bos.flush();
bos.close();
fos.close();
}
}
catch (ZipException e) {
throw e;
}
catch (IOException e) {
throw e;
}
}
}
unziptest.jsp:
<%@ page contentType="text/html; charset=Big5" errorPage="" %>
<%@ page import="com.andowson.UnZipBean" %>
<%
String zipFile = "c:\\temp\\test.zip";
String targetDirectory = application.getRealPath("/tmp");
UnZipBean uzb = new UnZipBean(zipFile, targetDirectory);
boolean succ = uzb.unzip();
if (succ) out.println(uzb.getZipFile() + " UnZipped");
%>
參考資料:
http://java.sun.com/developer/technicalArticles/Programming/compression/
http://www.wakhok.ac.jp/~tatsuo/sen97/10shuu/UnZip.java.html
|
 |
|
|
|
|
 |
|
|
http://unicode.coeurlumiere.com/
如果在資料庫中出現一些#開頭後面跟著一堆數字,然後再一個;號的字串,例如#20931;這就表示前端的網頁的字集不夠,輸入的字元被自動替換為Unicode的數字編號,我們可以透過查詢上面這個Unicode的表來還原。而#20931;可以在 第6頁查到。
|
 |
|
|
您可以看一下SystemGlobals.properties裡面的這幾個跟cahce有關的參數:
# ############
# Cache Stuff
# ############
topicsPerPage = 15
postsPerPage = 15
usersPerPage = 30
hot.topic.begin = 20
topic.recent = 50
posts.cache.enabled = false
posts.cache.size = 100
# Caching
topic.cache.enabled = true
security.cache.enabled = true
cache.engine.default = net.jforum.cache.DefaultCacheEngine
cache.engine.jboss = net.jforum.cache.JBossCacheEngine
jboss.cache.properties = ${config.dir}/jboss-cache-cluster.xml
cache.engine.implementation = ${cache.engine.default}
cacheable.objects = net.jforum.repository.BBCodeRepository, \
net.jforum.repository.RankingRepository, \
net.jforum.repository.SmiliesRepository, \
net.jforum.repository.ForumRepository, \
net.jforum.repository.TopicRepository, \
net.jforum.SessionFacade, \
net.jforum.repository.PostRepository, \
net.jforum.util.search.quartz.QuartzSearchIndexerJob, \
net.jforum.repository.Tpl, \
net.jforum.repository.RolesRepository, \
net.jforum.repository.SecurityRepository
cache.dir = cache
|
 |
|
|
|
請問您有修改newproject.sh的第7~17行的參數嗎?
我有個建議就是可否請您將Trac整個移掉重裝,然後按照我這篇文章的預設路徑去裝裝看,先排除掉路徑問題,如果裝得起來您可再自行調整路徑重新安裝一次。
|
 |
|
|
|
|
 |
|
|
|
因為OLAT的套件實在是太多了,如果要一個人獨立翻譯完,可能要花很久的時間,為便於推廣使用,希望有興趣使用OLAT繁體中文版的人可以與我聯絡。
註:本項工作為純志願性,並無任何金錢上的報酬。
|
 |
|
|
去年託同事在Java 認證日研討會上買了一張Sun的考試券,眼看今年8/31就要到期,當初是準備要考SCJP 5的,後來看了網路上有人說可以直接報SCJP 6,於是我就改報考SCJP 6了。
考試前我看了兩本書
SCJP Java 5 專業認證手冊=>已有新版 SCJP Java 6專業認證手冊
Java認證SCJP 5.0猛虎出閘=>已有新版 Java認證SCJP 6.0/5.0--猛虎出閘
建議的準備方法是詳讀第一本後再練習做第二本的180題,而且做的時候要先把答案蓋上,強迫自己思考。
另外關於SCJP 6加考的部分,我是上第一本書光碟內的超連結 http://osborne.onlineexpert.com/elearning/去下載MasterExam的第二份考題(免費)。
考試前,我去便利商店買了一瓶水,然後就去報到,我給櫃臺小姐看了一下身份證(有照片)和信用卡(有簽名),然後再翻了一下猛虎的考題。
進場前, 恆逸的考試中心有提供有鎖的櫃子,我把包包放進去,手機關機,然後我把那瓶水拿出來帶了進去,然後問了一下中間去上個上廁所可不可以,小姐回答說直接去就可以了!接著就開始作答了。
實際考試下來,猛虎出閘出現的題目大約有39題:
9,13,15,16,18,25,31,32,36,41,49,60,68,69
81,94,98,101,102,108,124,127,129,131,133,136,138
141,142,149,153,157,162,163,169,172,173,174,179
我當初報名時選成中文,結果題目是中文版的,又找不到地方切換成英文,滿不習慣的,大概作答了100多分鐘,還重頭檢查了一遍,最後實在不想煎熬下去了,就直接送出了。然後收了包包,走出去,櫃臺那邊已經印好成績單等我了。88% Pass! Oh Yeah!
最後歸納出一個心得:如果是看猛虎180題就要去考的人,建議報名時報英文版的,考前一天最好題目可以再做一次(蓋住答案),把做錯的勾起來。因為只要答對47題就過關了,所以如果有猛虎加持39題,再猜對個8題,考過應該不是難事!考試卷可以不用買可重考的了!(我當初買了可重考的算是多花了一千塊  )不過,最好還是準備好了再報考吧!如果可以先看過專業認證手冊後再來看猛虎出閘的考題,相信融會貫通後這些題目就都可以迎刃而解了!
參考網站:
http://www.developersbook.com/certifications/scjp/scjp6-certification.php
http://blog.yam.com/rexmen/article/15817394
http://www.javaworld.com.tw/jute/post/view?bid=17&id=232748&tpg=1&ppg=1&sty=3&age=0
http://osborne.onlineexpert.com/elearning/
|
 |
|
|
1.打開權限:到系統管理控制台->群組管理->一般使用者->權限->可以刪除文章->是
2.修改templates/default/post_show_action_buttons_inc.htm裡面的22行:
<#if canRemove && (((post.userId == session.userId) && (session.userId != 1)) || isModerator || isAdmin)>
3.重新載入JForum即可。
|
 |
|
|
1.請加上* = r到/home/trac/projects/svnaccess的[/]下,如下:
[/]
* = r
admin = rw
[project1:/]
* = r
admin = rw
user1 = rw
user2 =rw
2.請問您有沒有執行trac_setup.sh的98-142行部分,可否檢視一下這幾個設定檔:
/etc/httpd/conf.d/python.conf
/etc/httpd/conf.d/subversion.conf
 檢查/etc/httpd/conf.d/python.conf的檔尾有沒有下列設定:
<Location /projects>
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /home/trac/projects
PythonOption TracUriRoot /projects
SetEnv PYTHON_EGG_CACHE /tmp
</Location>
<LocationMatch "/projects/[^/]+/login">
AuthType Basic
AuthName "Trac"
AuthUserFile /home/trac/projects/.htpasswd
Require valid-user
</LocationMatch>
 檢查/etc/httpd/conf.d/subversion.conf的檔尾有沒有下列設定:
<Location /svn>
DAV svn
SVNParentPath /home/trac/repos
<LimitExcept GET PROPFIND OPTIONS REPORT>
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /home/trac/projects/.htpasswd
AuthzSVNAccessFile /home/trac/projects/svnaccess
Require valid-user
</LimitExcept>
</Location>
|
 |
|
|
|
|