Oracle XE change password for System.

If Linux/Unix

export ORACLE_SID=XE
export ORACLE_HOME=[Oracle_XE_install_path]
sqlplus / as sysdba

SQL> alter user sys indentified by [new_password];

SQL> alter user system indentified by [new_password];



If windows
set ORACLE_SID=XE
set ORACLE_HOME=[Oracle_XE_install_path]
sqlplus / as sysdba

SQL> alter user sys indentified by [new_password];

SQL> alter user system indentified by [new_password];
String is immutable whereas StringBuffer and StringBuilder can change their values.

The only difference between StringBuffer and StringBuilder is that StringBuilder is unsynchronized whereas StringBuffer is synchronized. So when the application needs to be run only in a single thread then it is better to use StringBuilder. StringBuilder is more efficient than StringBuffer.

Criteria to choose among String, StringBuffer and StringBuilder

1. If your text is not going to change use a string Class because a String object is immutable.
2. If your text can change and will only be accessed from a single thread, use a StringBuilder because StringBuilder is unsynchronized.http://www.blogger.com/img/blank.gif
3. If your text can changes, and will be accessed from multiple threads, use a StringBuffer because StringBuffer is synchronous.

Ref : link 1


link 2

link 3

Mismatched serialization UIDs

Caused by: org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge :
Mismatched serialization UIDs :
Source (RepId RMI:com.model.HAHAResult:1335A78CB1E6EDB7:690F13781C0374C1) = 690F13781C0374C1 whereas
Target (RepId RMI:com.model.HAHAResult:359C570FBD100732:584576386E6E2CBD) = 584576386E6E2CBD vmcid: IBM minor code: 896 completed: No


ปัญหาเกิดจาก com.model.HAHAResult ไม่ได้ประกาศ serialVersionUID ทำให้เรียก Object ผ่าน RMI
มีปัญหาฟ้องว่า uid ต้นทางกับ ปลายทางไม่ตรงกัน ดูข้อมูลได้จาก entry เรื่องของ Serializable

วิธีแก้ที่คือ ถ้าสร้าง class แล้ว implements java.io.Serializable ต้องสร้าง serialVersionUID เสมอ
พอเพิ่มแล้ว compile class ใหม่ก็ใช้ได้แล้ว

แต่เนื่องจาก class ตัวนี้ เป็น ejb (แล้วยังไง compile ใหม่ก็เสร็จ) แล้วมีการนำ ejb client ไปใช้ที่ระบบอื่นด้วย
ทำให้ถ้า gen client ใหม่ ก็ต้องส่งให้ระบบอื่นด้วยจะทำยังไงแค่แก้ฝั่ง ejb โดยไม่กระทบ client

เลยคิดว่า งั้นก็ สร้าง serialVersionUID ที่มีค่า uid เหมือนกับ ตัวแปล ที่ client
แต่เราจะรู้ค่า uid ที่อยู่ใน jvm ได้ยังไง
จากที่หาข้อมูลมาที่ http://download.oracle.com/javase/6/docs/platform/serialization/spec/class.html (บอกวิธีคำนวน uid ด้วย)

ทำให้รู้จัก ObjectStreamClass จะมี method getSerialVersionUID


String name = "com.model.HAHAResult";
Class c = Class.forName(name);

ObjectStreamClass oc = ObjectStreamClass.lookup( c );
long uid = oc.getSerialVersionUID();


เราก็จะได้ ค่า uid ของ class ที่ต้องการแล้ว

แต่ทั้งนี้ทั้งนั้น Entry นี้จะไม่เกิด ถ้าสร้าง class แล้ว implements java.io.Serializable ต้องสร้าง serialVersionUID เสมอ

The command line length depends on the OS:

Windows NT, the command line is limited to 256 characters.
Windows 2000, the command line is limited to 2046 characters.
Windows XP, the command line is limited to 8190 characters.

For all OS's NTFS and FAT allows pathnames of up to 260 characters.

If you're not reaching any of these limits with your command line, then maybe telnet has it's own input limit. In which case you may want to break up your input line with a continuation character, which I think is "\" at the end of the line.

unix ,This is in the /usr/include/limits.h file
ex.the limit there is _POSIX_PATH_MAX = 255 per file name.
_POSIX_MAX_INPUT : Maximum number of bytes allowed in a terminal input queue. Value: 255

link : description for limits.h
Solution:

1. download activation.jar http://java.sun.com/javase/technologies/desktop/javabeans/jaf/downloads/index.html or http://www.java2s.com/Code/Jar/GHI/Downloadactivationjar.htm

2. download mail.jar http://java.sun.com/products/javamail/downloads/index.html

3. add these two jar’s to the project

คู่มือการใช้ IP Msg


คู่มื่อการใช้ IP Msg

JavaScript String Replace All

The JavaScript function for String Replace replaces the first occurrence in the string. The function is similar to the php function str_replace and takes two simple parameters. The first parameter is the pattern to find and the second parameter is the string to replace the pattern with when found. The javascript function does not Replace All...



str = str.replace(”find”,”replace”)



To ReplaceAll you have to do it a little differently. To replace all occurrences in the string, use the g modifier like this:



str = str.replace(/find/g,”replace”)

การ Set Connection Timeout ใน Socket

มีสองตัวให้ Config น่ะครับ เป็น soTimeout ของ Socket อันนี้คือระยะเวลา Ideal ของ Socket ถ้าเกินก็จะ Timeout ออกไปต้อง Connect ใหม่ กับ ตอน socket.connect (InetSocketAddress, Timeout) อันนี้จะเป็น Timeout ของการรอตอบกลับค่าจาก External System ที่เราไปเรียก ซึ่ง ตามตัวอย่างข้างล่าง



InetSocketAddress socketAddr = new InetSocketAddress(url,port);
Socket socket = new Socket();
socket.connect(socketAddr,readTimeout);
socket.setSoTimeout(idealTimeout);



Often we need to create a (client) socket connection in java but we do not want to wait indefinitely for the connection to open. We need a way to timeout socket connections. Two solutions and recommended code.

Previously the only way was to create the socket in a Thread. And then kill the thread if it is running beyond a threshold time limit. This had two problems. First Thread.kill or Thread.suspend are deprecated methods and with good reason. Their availability cannot be ensured in future versions of Java. Secondly the process was clumsy to say the least. Now we have a better method since JDK 1.4.

java.net.Socket supports timeout from JDK1.4 onwards. The following is a sample code to enable socket timeout in Java. In this sample 500 milliseconds is chosen as timeout value.


// Open a socket without any parameters. It hasn’t been binded or connected
Socket sock = new Socket();

// Bind to a local ephemeral port
sock.bind(null);

// Connect to google.com on port 80 with a timeout of 500 milliseconds
sock.connect(new InetSocketAddress(”www.google.com”, 80), 500);

// Your code goes here

// Close the socket.
sock.close();

18. ภาคผนวก : หลักเกณฑ์ควรรู้ ก่อนกู้เงิน

17. อย่ามัวแต่ดีใจ เมื่อเงินกู้ที่ขอได้อนุมัติ

16.หลักฐานครบ อนุมัติเงินกู้ไม่ล่าช้า

15. ต้องรอนานแค่ไหน กว่าจะได้เข้าบ้าน

14.วิธียื่นกู้ ที่รู้วงเงินทันใจ

13.หาข้อมูลให้แน่น ถ้ายังไม่แม่นเรื่องซื้อบ้าน

12.สิ่งแรกที่คุณควรทำเมื่อความพร้อมมีเกินร้อย

11. สอบถามให้ชัด ทำไมธนาคารไม่อนุมัติสินเชื่อ

10. คิดคำนวณเงินกู้ มีตัวอย่างให้ดูง่าย ๆ

9.รู้เกณฑ์อนุมัติ กู้ถนัดยิ่งขึ้น

8. คลายข้อสงสัย ทำไมต้องประเมินราคาทรัพย์สิน

ึ7. เงินงวดรายเดือน ใช้หลักอะไรคิดคำนวณ

6. สำรวจกระเป๋า ผ่อนหนัก ผ่อนเบาก็สบาย

5. เก็บหอมรอมริบ พิชิตเงินดาวน์

4. เครดิตไม่เข้าตา ธนาคารจะพิจารณาอะไรแทนได้

3. เครดิตดี มีชัยไปกว่าครึ่ง

2. การงานมั่นคง บ้านสมดังใจ

1. ตรวจตราความพร้อมก่อนซื้อบ้าน

Hibernate call store procedure

In Hibernate, there are three approaches to call a database store procedure.
1. Native SQL – createSQLQuery

You can use createSQLQuery() to call a store procedure directly.

Query query = session.createSQLQuery(
"CALL GetStocks(:stockCode)")
.addEntity(Stock.class)
.setParameter("stockCode", "7277");

List result = query.list();
for(int i=0; i Stock stock = (Stock)result.get(i);
System.out.println(stock.getStockCode());
}


2. NamedNativeQuery in annotation
Declare your store procedure inside the @NamedNativeQueries annotation.


//Stock.java
...
@NamedNativeQueries({
@NamedNativeQuery(
name = "callStockStoreProcedure",
query = "CALL GetStocks(:stockCode)",
resultClass = Stock.class
)
})
@Entity
@Table(name = "stock")
public class Stock implements java.io.Serializable {
...


Call it with getNamedQuery().


Query query = session.getNamedQuery("callStockStoreProcedure")
.setParameter("stockCode", "7277");
List result = query.list();
for(int i=0; i Stock stock = (Stock)result.get(i);
System.out.println(stock.getStockCode());
}


3. sql-query in XML mapping file

Declare your store procedure inside the “sql-query” tag.

<!-- Stock.hbm.xml -->
...
<hibernate-mapping>
<class name="com.mkyong.common.Stock" table="stock" ...>
<id name="stockId" type="java.lang.Integer">
<column name="STOCK_ID" />
<generator class="identity" />
</id>
<property name="stockCode" type="string">
<column name="STOCK_CODE" length="10" not-null="true" unique="true" />
</property>
...
</class>

<sql-query name="callStockStoreProcedure">
<return alias="stock" class="com.mkyong.common.Stock"/>
<![CDATA[CALL GetStocks(:stockCode)]]>
</sql-query>

</hibernate-mapping>


Call it with getNamedQuery().


Query query = session.getNamedQuery("callStockStoreProcedure")
.setParameter("stockCode", "7277");
List result = query.list();
for(int i=0; i Stock stock = (Stock)result.get(i);
System.out.println(stock.getStockCode());
}


Conclusion

The above three approaches are doing the same thing, call a store procedure in database. There are not much big different between the three approaches, which method you choose is depend on your personal prefer.

Ref : link1
Supposing you have the following Oracle Stored procedure:

CREATE FUNCTION agenda RETURN SYS_REFCURSOR
AS
my_cursor SYS_REFCURSOR;
BEGIN
OPEN my_cursor FOR
SELECT id,person_name,person_surname,person_address
FROM Person;
RETURN my_cursor;
END;

Invoking it from Hibernate requires mapping the Stored Procedure in the Person class.


<sql-query name="SP_agenda" callable="true">
<return alias="ev" class="Person">
<return-property name="id" column="id"/>
<return-property name="name" column="person_name"/>
<return-property name="surname" column="person_surname"/>
<return-property name="address" column="person_address"/>
</return>
{ ? = call agenda() }
</sql-query>


Then, you can execute the procedure just like a normal Query:

Query query = session.getNamedQuery("SP_agenda");
List results = query.list();

กาลามสูตร

กาลามสูตร คือ พระสูตรที่พระพุทธเจ้าทรงแสดงแก่ชาวกาลามะ หมู่บ้านเกสปุตติยนิคม แคว้นโกศล (เรียกอีกอย่างว่า เกสปุตติยสูตร หรือเกสปุตตสูตร ก็มี[1]) กาลามสูตรเป็นหลักแห่งความเชื่อที่พระพุทธองค์ทรงวางไว้ให้แก่พุทธศาสนิกชน ไม่ให้เชื่อสิ่งใด ๆ อย่างงมงายโดยไม่ใช้ปัญญาพิจารณาให้เห็นจริงถึงคุณโทษหรือดีไม่ดีก่อนเชื่อ มีอยู่ 10 ประการ ได้แก่

  1. อย่าเพิ่งเชื่อตามที่ฟังๆ กันมา
  2. อย่าเพิ่งเชื่อตามที่ทำต่อๆ กันมา
  3. อย่าเพิ่งเชื่อตามคำเล่าลือ
  4. อย่าเพิ่งเชื่อโดยอ้างตำรา
  5. อย่าเพิ่งเชื่อโดยนึกเดา
  6. อย่าเพิ่งเชื่อโดยคาดคะเนเอา
  7. อย่าเพิ่งเชื่อโดยนึกคิดตามแนวเหตุผล
  8. อย่าเพิ่งเชื่อเพราะถูกกับทฤษฎีของตน
  9. อย่าเพิ่งเชื่อเพราะมีรูปลักษณ์ที่ควรเชื่อได้
  10. อย่าเพิ่งเชื่อเพราะผู้พูดเป็นครูบาอาจารย์ของตน


top