Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JavaÊÂÎñAPI

 JavaÊÂÎñAPI£¨JTA£»Java Transaction API£©ºÍËüµÄͬ°ûJavaÊÂÎñ·þÎñ(JTS£»Java TransactionService)£¬ÎªJ2EEƽ̨ÌṩÁË·Ö²¼Ê½ÊÂÎñ·þÎñ¡£Ò»¸ö·Ö²¼Ê½ÊÂÎñ£¨distributedtransaction£©°üÀ¨Ò»¸öÊÂÎñ¹ÜÀíÆ÷£¨transaction manager£©ºÍÒ»¸ö»ò¶à¸ö×ÊÔ´¹ÜÀíÆ÷(resource manager)¡£Ò»¸ö×ÊÔ´¹ÜÀíÆ÷£¨resource manager£©ÊÇÈÎÒâÀàÐ͵ij־û¯Êý¾Ý´æ´¢¡£ÊÂÎñ¹ÜÀíÆ÷£¨transaction manager£©³Ðµ£×ÅËùÓÐÊÂÎñ²ÎÓëµ¥ÔªÕßµÄÏ໥ͨѶµÄÔðÈΡ£Ï³µÕ¾ÏÔʾÁËÊÂÎñ¹ÜÀíÆ÷ºÍ×ÊÔ´¹ÜÀíµÄ¼äµÄ¹Øϵ¡£
¡¡¡¡JTAÊÂÎñ±ÈJDBCÊÂÎñ¸üÇ¿´ó¡£Ò»¸öJTAÊÂÎñ¿ÉÒÔÓжà¸ö²ÎÓëÕߣ¬¶øÒ»¸öJDBCÊÂÎñÔò±»ÏÞ¶¨ÔÚÒ»¸öµ¥Ò»µÄÊý¾Ý¿âÁ¬½Ó¡£ÏÂÁÐÈÎÒ»¸öJavaƽ̨µÄ×é¼þ¶¼¿ÉÒÔ²ÎÓëµ½Ò»¸öJTAÊÂÎñÖУº
¡¡¡¡.JDBCÁ¬½Ó
¡¡¡¡.JDO PersistenceManager ¶ÔÏó
¡¡¡¡.JMS ¶ÓÁÐ
¡¡¡¡.JMS Ö÷Ìâ
¡¡¡¡.ÆóÒµJavaBeans£¨EJB£©
¡¡¡¡.Ò»¸öÓÃJ2EE Connector Architecture ¹æ·¶±àÒëµÄ×ÊÔ´·ÖÅäÆ÷¡£
¡¡¡¡Ê¹ÓÃJTAµÄÊÂÎñ»®·Ö 
¡¡¡¡ÒªÓÃJTAÀ´»®·ÖÒ»¸öÊÂÎñ£¬Ó¦ÓóÌÐòµ÷ÓÃjavax.transaction.UserTransaction½Ó¿ÚÖеķ½·¨¡£Ê¾Àý4ÏÔʾÁËÒ»¸öµäÐ͵ÄJNDIËÑË÷µÄUseTransaction¶ÔÏó¡£
import javax.transaction.*£»
import javax.naming.*£»
// ...
InitialContext ctx = new InitialContext()£»
Object txObj = ctx.lookup("java:comp/UserTransaction"£»)£»
UserTransaction utx = (UserTransaction) txObj£» 
Ó¦ÓóÌÐòÓÐÁËUserTransaction¶ÔÏóµÄÒýÓÃÖ®ºó£¬¾Í¿ÉÒÔÏóʾÀý5ÄÇÑùÀ´Æð¶¯ÊÂÎñ¡£
utx.begin()£»
// ...
DataSource ds = obtainXADataSource()£»
Connection conn = ds.getConnection()£»
pstmt = conn.prepareStatement("£»UPDATE MOVIES ..."£»)£»
pstmt.setString(1£¬ "£»Spinal Tap"£»)£»
pstmt.executeUpdate()£»
// ...
utx.commit()£»
// ... 
µ±Ó¦ÓóÌÐòµ÷ÓÃcommit()ʱ£¬ÊÂÎñ¹ÜÀíÆ÷ʹÓÃÁ½¶ÎÌύЭÒéÀ´½áÊøÊÂÎñ¡£JTAÊÂÎñ¿ØÖƵķ½·¨£º
javax.transaction.UserTransaction½Ó¿ÚÌṩÁËÏÂÁÐÊÂÎñ¿ØÖÆ·½·¨£º
public void begin()
public void commit()
public void rollback()
public void getStatus()
public void setRollbackOnly()
public void setTransactionTimeout(int) 
Ó¦ÓóÌÐòµ÷ÓÃbegin()À´Æð¶¯ÊÂÎñ£¬¼´¿Éµ÷ÓÃcommit()Ò²¿ÉÒÔµ÷ÓÃrollback()À´½áÊøÊÂÎñ¡£
¡¡¡¡Ê¹ÓÃJTAºÍJDBC
¡¡¡¡¡¡¿ª·¢ÈËÔ±¾­³£Ê¹ÓÃJDBCÀ´×÷ΪDAOÀàÖеĵײãÊý¾Ý²Ù×÷¡£Èç¹û¼Æ»®Ê¹ÓÃJTAÀ´»®·ÖÊÂÎñ£¬Ä㽫ÐèÒ


Ïà¹ØÎĵµ£º

javaÈëÃÅ

 Javaѧϰ´ÓÈëÃŵ½¾«Í¨ 
Ò»¡¢ JDK (Java Development Kit) 
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......

1¡¢ÔõÑùѧϰJava?

 1.Á˽âJavaµÄÔ­Àí£º
       Ê×ÏÈÒªÁ˽âÕû¸öJavaµÄ´óÖ½ṹ¡¢¹¤×÷»·¾³¡¢ÀúÊ·¡£ÔÚÕâ¸ö¹ý³ÌÖÐÒª¸ãÃ÷°×Java´ÓÔ´´úÂëµ½×îºóÐéÄâ»úÀïÃæÖ´ÐеÄÒ»¸ö¹ý³ÌÊÇÔõÑùµÄ¡£
2.ѧϰJavaÓï·¨£º
      JavaÀïÃæÖ»ÓÐ50¶à¸ö¹Ø¼ü×ÖºÍһЩÔËËã·û¡£Óï·¨½á¹¹¾ÍÖ»ÓÐ˳Ðò¡¢Ìõ¼þ¡¢Ñ­»· ......

JavaÅàѵ×ܽá

1¡¢  Web.xml
1£©  ÅäÖÃhibernate
<context-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>/WEB-INF/dbConnectionContext.xml /WEB-INF/serviceContext.xml</param-value> ......

ÀûÓÃJava API¶Ô×Ö·û´®½øÐмÓÃܽâÃÜ£¨DES¼ÓÃÜËã·¨£©

 /*Decryptor*/
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
/**
 * Decrypt the password get form Xpress GUI
 */
public class Decryptor{
  
//¼ÓÃÜ    
  ......

Java ¶àÏ̱߳à³ÌÖ®Èý£ºsynchronized ¹Ø¼ü×ÖµÄʹÓÃ

Java ¶àÏ̱߳à³ÌÖ®Èý£ºsynchronized ¹Ø¼ü×ÖµÄʹÓÃ
        ´øÓÐ synchronized ¹Ø¼ü×ֵķ½·¨´ú±íÕâ¸ö·½·¨¼ÓËø¡£Ç¡µ±¶øÓÖÁé»îµØÔËÓà synchronized ¹Ø¼ü×Ö£¬ÊǶàÏ̱߳à³ÌµÄ±ØÐ޿Ρ£
¡¡¡¡1¡¢synchronized¹Ø¼ü×ÖµÄ×÷ÓÃÓòÓжþÖÖ£º
¡¡¡¡1£©ÊÇij¸ö¶ÔÏóʵÀýÄÚ£¬synchronized aMethod(){}¿ÉÒÔ·ÀÖ¹¶à ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ