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

In Linux:
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

http://www.ibm.com/developerworks/java/library/j-ts2.html?ca=dgr-jw22SprinEJBtrans&S_TACT=105AGX59&S_CMP=grsitejw22

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

  • Create a certificate keystore by executing the following command:
    keytool -genkey -alias tomcat -keyalg RSA
    and specify a password value of "changeit".
  • Uncomment the "SSL HTTP/1.1 Connector" entry in $CATALINA_HOME/conf/server.xml and tweak as necessary.
  • Add keystorePass element if you used a different keystore (and Certificate) password than the one Tomcat expects (changeit).
  • Delete the certificate keystore:
    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?