2009年11月6日 星期五
Change user profile path in windows xp
ProfileImagePath registry value
The ProfileList registry key contains some sub-keys, which are nothing but the list of User Account Security Identifiers (SID). Each of the SID represents an Account. The key is located here:
HKEY_LOCAL_MACHINE \ SOFTWARE\ Microsoft\ Windows NT \ CurrentVersion \ ProfileList
2009年9月8日 星期二
2009年7月20日 星期一
How to change JBoss default port
1. Open the JBoss Folder
2. Goto its Deploy folder.
3. Goto the jbossweb-tomcat55.sar
4. Find out the server.xml inside that folder. Actually this is the server configure file of the BuildIn Tomcat.
5. Find the folowing Tag
<Connector port="8080" address="${jboss.bind.address}"…….
6. Change the port number here.
7. Restart the server.
Jboss預設只能以127.0.0.1本機存取,如要改變binding address,啟動時指令如下:
run -c default -Djboss.bind.address=0.0.0.0
用run -h可查看help
2009年7月19日 星期日
Install PAE enabled kernel in 32 bit Ubuntu to use 4GB RAM
$ sudo apt-get update
$ sudo sudo apt-get install linux-headers-server linux-image-server linux-server
$ sudo reboot
2009年7月15日 星期三
修改Oracle Express的HTTP port
Oracle database express edition default http port是8080,容易與其他的web server衝到,以下指令可將其改為8087
C:\>sqlplus /nolog
SQL> connect
Enter user-name: system
Enter password: <輸入密碼>
Connected.
SQL> Exec DBMS_XDB.SETHTTPPORT(8087);
PL/SQL procedure successfully completed.
SQL>quit
Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 – Production
修改後立即生效。
2009年6月8日 星期一
2009年5月4日 星期一
使用JCIFS存取samba folder
JCIFS web site: http://jcifs.samba.org/
Sample code:
jcifs.Config.setProperty("jcifs.smb.client.domain", "APNET");
jcifs.Config.setProperty("jcifs.smb.client.username", "apuser");
jcifs.Config.setProperty("jcifs.smb.client.password", "appassword");
java.io.FileInputStream input = new java.io.FileInputStream("d:/temp/test.txt");
jcifs.smb.SmbFileOutputStream output = new jcifs.smb.SmbFileOutputStream(
"smb://hostname/upload$/test.txt");
byte[] b = new byte[8192];
int n;
while ((n = input.read(b)) > 0) {
System.out.write(b, 0, n);
output.write(b, 0, n);
}
input.close();
output.close();
2009年3月13日 星期五
用 Spring 取得 Oracle Sequence 及 Hibernate 的設定
Oracle:
create sequence ORDER_SEQ
start with 1
increment by 1
nomaxvalue;
Spring:
使用Spring提供的org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer:
OracleSequenceMaxValueIncrementer incr = new OracleSequenceMaxValueIncrementer(dataSource, "ORDER_SEQ");
int seq = incr.nextIntValue();
Hibernate:
<id name="id" column="ID" type="java.lang.Long">
<generator class="sequence">
<param name="sequence">ORDER_SEQ</param>
</generator>
</id>
2009年3月11日 星期三
Find which process has occupied which port
lsof – list open files
The syntax for using "lsof" is:
lsof -i tcp:3480
or
lsof -i udp:3480
if you are interested in port 3480, over the appropriate protocol, TCP or UDP...
In Windows:
C:\>netstat -abno
使用中連線
協定 本機位址 外部位址 狀態 PID
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 1932
[httpd.exe]
TCP 0.0.0.0:113 0.0.0.0:0 LISTENING 3580
[ident.exe]
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 800
RpcSs
[svchost.exe]
TCP 0.0.0.0:1025 0.0.0.0:0 LISTENING 472
[wininit.exe]
In AIX:
netstat -Aa | gret 8080
rmsock xxxxxxxx tcpcb
ps -ef|grep thepid
2009年3月10日 星期二
Transaction strategies: Models and strategies overview
The Java platform supports six types of transaction attributes, regardless of whether you are using EJB or the Spring Framework:
Required, Mandatory, RequiresNew, Supports, NotSupported, Never.2009年3月5日 星期四
Running servlet container behind IIS
Installing and Configuring the Microsoft IIS Weblogic proxy Plug-In
http://e-docs.bea.com/wls/docs92/plugins/isapi.html
The Apache Tomcat Connector - Reference Guide - Configuring IIS
http://tomcat.apache.org/connectors-doc/reference/printer/iis.html
Running Tomcat behind IIS
http://www.boplicity.net/confluence/display/Tomcat/Running+Tomcat+behind+IIS
Windows2003下完美配置整合IIS 6+Jre 1.6+Tomcat 6.0.18 - windows 服务器
http://blog.chinaunix.net/u2/69106/showart_1417949.html
整合 IIS 5.1 和 Tomcat 5.5 的步驟
http://xml.nchu.edu.tw/blogs/?p=48
ONJava.com Configuring Tomcat with IIS Web Server
http://www.onjava.com/lpt/a/2829
2009年3月4日 星期三
Tomcat 5.5 SSL Configuration
keytool -genkey -alias tomcat -keyalg RSA
and specify a password value of "changeit".
keytool -delete -alias tomcat
Change the password from “changeit” to “newpass”:
keytool -keypasswd -alias tomcat -keypass changeit -new newpass
The keystore is by default stored in a file named .keystore in the user's home directory, as determined by the "user.home" system property.
Read http://java.sun.com/j2se/1.3/docs/tooldocs/win32/keytool.html for more information about keytool.
Tomcat 5.5 JNDI設定
1. conf/context.xml:
<Resource name="jdbc/eflow"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
username="eflow"
password="eflow123"
url="jdbc:oracle:thin:@localhost:1521:orcl"
maxActive="10"
maxIdle="0"
factory="org.apache.commons.dbcp.BasicDataSourceFactory" />
2. web.xml
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/eflow</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
2009年3月3日 星期二
How do I change the IP address on Oracle 10g
If the server's IP address changed, these are the first things I would look at:
The TNSNAMES.ORA file on the client -- does it have the IP address hardcoded? If so, change it. Does it use the machine name? If so, does the machine name resolve to the correct IP address on your client machine?
The LISTENER.ORA file on the server -- does it explicitly specify the old IP address as its listening address?
2009年2月4日 星期三
用java壓縮tar檔
package mytest;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.tools.tar.TarEntry;
import org.apache.tools.tar.TarOutputStream;
public class AntTarTest {
public static void main(String[] args) throws Exception {
String[] inputFiles = new String[] { "D:/txt/network.txt",
"D:/txt/sql.txt" };
new AntTarTest().tar("d:/AntTarTest.tar", inputFiles);
}
public void tar(String tarFileName, String[] inputFiles) throws IOException {
TarOutputStream out = new TarOutputStream(new FileOutputStream(
tarFileName));
int buffersize = 1024;
byte[] buf = new byte[buffersize];
for (int i = 0; i < inputFiles.length; i++) {
File file = new File(inputFiles[i]);
TarEntry te = new TarEntry(file.getName());
te.setSize(file.length());
out.putNextEntry(te);
FileInputStream in = new FileInputStream(file);
int count;
while ((count = in.read(buf, 0, buffersize)) != -1)
out.write(buf, 0, count);
out.closeEntry();
in.close();
}
out.close();
System.out.println("compress ok.");
}
}