posts - 97,  comments - 93,  trackbacks - 0
           
          Today with tomcat admin, a Graphic interface for us to config the JNDI for our program,I configured the context and connection pool jioning IBM DB2 ExC-9.Actually,JNDI is an API specified in Java technology that provides naming and directory functionality to applications written in the Java programming language. It is designed especially for the Java platform using Java's object model. Using JNDI, applications based on Java technology can store and retrieve named Java objects of any type. In addition, JNDI provides methods for performing standard directory operations, such as associating attributes with objects and searching for objects using their attributes (Name-Value,context).JNDI is also defined independent of any specific naming or directory service implementation. It enables applications to access different, possibly multiple, naming and directory services using a common API. Different naming and directory service providers can be plugged in seamlessly behind this common API. This enables Java technology-based applications to take advantage of information in a variety of existing naming and directory services, such as LDAP, NDS, DNS, and NIS(YP), as well as enabling the applications to coexist with legacy software and systems. Using JNDI as a tool, we can build new powerful and portable applications that not only take advantage of Java's object model but are also well-integrated with the environment in which they are deployed.
          A directory is typically used to associate attributes with objects. A person object, for example, can have a number of attributes, such as the person's surname, fisrtName,telephone numbers, electronic mail address and so on. Using JNDI, to retrieve the email address of a person object, the code looks as follows.
          1 Attribute personAttribute=directory.getAttributes(personName).get("email");
          2 String email = (String)personAttribute.get();
          (Recently,finding that blogjava can help us format our code,that's perfect,but if can max the editor area which will enhance the function and coursely be better:).)
          An intuitive model for the Java programmer is to be able to lookup objects like printers and databases from the naming/directory service. Using JNDI, to lookup a printer object, the code looks as follows. (it's important and most used)
          1 Printer printer =(Printer)namespace.lookup(printerName);
          2 printer.print(document);

          posted @ 2007-04-08 15:10 wqwqwqwqwq 閱讀(473) | 評(píng)論 (0)編輯 收藏

          //*******************The Log class
          import java.io.BufferedWriter;
          import java.io.File;
          import java.io.FileWriter;
          import java.io.IOException;
          import java.uitl.Date;
          import java.text.DateFormat;

          public class Log{
             private static final String filePath = PropertyReader.getResource("Log_File_Path");//Supposing we have define in the last ProperyReader class and the file
            
             public static final String EXCEPTION                  =   "Exception";
             public static final String CREATE_STAFF           =   "Create Staff";
             public static final String EDIT_STAFF                 =   "Edit Staff";
             public static final String DELETE_STAFF            =   "Delete Staff";
             public static final String RECORD_HAS_EXIST  =   "Record Has Exist";

             public static void log(String msg_type, Exception e){
                StringBuffer errMsg = new StringBuffer(e.toString);
               
                for(int i=0;i<e.getStackTrace().length;i++){
                   errMsg.append("\n\t at");
                   errMsg.append(e.getStackTrace()[i].toString);
                }
                log(msg_type,errMsg.toString());
                OptionPanel.showErrMsg("Sorry,System may have an error \n System will exit");
                System.exit(-1);
             }

            public static void log(String msg.type,Staff staff){
               String msg = null;
               if(msg_type == CREATE_STAFF){
                   msg = staff.toString() + "has benn created";
               }else if(msg_type == EDIT_STAFF){
                   msg = staff.toString() + "has been Changed";
               }else if(msg_type == DELETE_STAFF){
                   msg = staff.toString() + "has been Deleted";
               }else if(msg_type == RECORD_HAS_EXIST){
                   msg = staff.toString() + "has exist in the database";
               }
               log(msg_type,msg);
            }

            private static void log(String msg_type,String msg){
                BufferedWriter out = null;
                DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
               
                try{
                  out = new BufferedWriter(new FileWriter(getLogFilePath(),true));//如果為 true,則將字節(jié)寫(xiě)入文件末尾處,而不是寫(xiě)入文件開(kāi)始處
                  out.write("["+df.format(new Date()) + "] <" + msg_type + "> :" + msg);
                  out.newline();
                  out.newline();
                }catch(IOException e){
                    e.printStackTrace();
                }finally{
                   try{
                     if(out!=null){
                        out.close();
                     }
                   }catch(IOException e){
                      e.printStackTrace();
                   }
                }
            }

            private static String getLogFilePath(){
               File logDir = new File(filePath);
               if(!logDir.exists()){
                 logDir.mkdir();
               }
              
               int i = 1;
               String fileName = filePath + "log_";
               File file = new File(fileName + i + ".txt");
             
               while(file.exists() && file.length() > 30000L) {
                   i++;
                   file = new File(fileName + i + ".txt");
               }
             
                return fileName + i + ".txt"
            }
          }

          //*****************************The OptionPanel Dialog Class for the Log Class
          import javax.swing.JOptionPane;

          public class OptionPanel {
             private static final String appTitle = PropertyReader.getResource("App_Title");//suposing the file has been established and the property app-title stands for the name of application
             private static final MainFrame frame = MainFrame.getMainFrame();

             public static void showWarningMsg(String msg){
                JOptionPane.showMessageDialog(frame,msg,appTitle,JOptionPane.WARNING_MESSAGE);
             }
             public static void showErrMsg(String msg){
                 JOptionPane.showMessageDialog(frame,msg,appTitle,JOptionPane.Error_MESSAGE);
             }
             public static int showConfirmMsg(String msg){
                  return JOptionPane.showConfirmDialog(frame,msg,appTitle,JOptionPane.YES_NO_OPTON,JOptionPane.QUESTION_MESSAGE);
             }
          }

          posted @ 2007-04-05 10:01 wqwqwqwqwq 閱讀(876) | 評(píng)論 (1)編輯 收藏

          In a project, we can write a class to read the properties.As following,

          import java.io.InputStream;
          import java.io.IOException;
          import java.util.Properties;

          public class PropertyReader{
             private static Properties property = null;
            
             static{
                InputSteam stream = null;
                try{
                  stream=PropertyReader.class.getResourceAsStream("/resource/properties.properties");
                  property = new Properties();
                  property.load(stream);
                }catch(IOException e){
                    e.printStackTrace();
                }finally{
                    if(stream != null){
                       try{
                          stream.close();
                       }catch(IOException e){
                          e.printStackTrace();
                       }           
                    }
                }
             }
             public static String getResource(String key){
               if(property == null){
                 return null;// init error;
               }
               
               return property.getProperty(key);
             }
          }

          posted @ 2007-04-05 08:13 wqwqwqwqwq 閱讀(485) | 評(píng)論 (0)編輯 收藏
          These days I want to review some java classes and post them,cos i come to realize that i hava been coming to forget some of them, my god,Katrina,....:) it's really the sound,and u ? ...regarding MVC,cos be delayed, and may be will better.

          List a class to use the title Properties.

          import java.util.Properties;
          import java.io.FileInputStream;
          import java.io.FileOutputStream;
          import java.io.FileNotFoundException;
          import java.io.IOException;

          public class FirstDayTestProperties {
             public static void main(String[] args) throws Exception{
                 Properties ProTest = new Properties();
                 String  fileName="PropertiesTest.properties";
                
                 try{
                    ProTest.setProperty("lastDir","C:\\PropertyTest");
                    ProTest.store(new FileOutputStream(fileName),null);
                 }catch(IOException e){
                      e.printStackTrace();
                 }

                 try{
                    FileInputStream inStream=new FileInputStream(fileName);
                    ProTest.load(inStream);
                    ProTest.list(System.out);
                 }catch(FileNotFoundException e){
                    e.printStackTrace();
                 }
             }
          }
          The class I just write now without any testing,but i think it seems no errors:).Share.

          posted @ 2007-04-04 21:32 wqwqwqwqwq 閱讀(482) | 評(píng)論 (0)編輯 收藏
          U may come across model view controller desigh pattern.It was first introduced by  Trygve Reenskaug. More details,MVC can be broken down into three elements.
          <1>Module  Usually,in enterprise software,it presents the logic of the commercial bean.To the SE Swing GUI,it contains data and the rules that govern access to and updates of this data.
          <2>View  It specifies exactly how the module data should be presented,changing with the model data.
          <3>Controller   Controller defines all the methods connecting to the user action which are called by the View.
          Especially,the model doesn't carry a reference to the view but instead uses an event-notification model to notify insteaded parties of a change.One of the consequences of this powerful design is that many views can have the same model.When a change in the data model occurs,each view is notified by a property change event and can change itself accordingly.Hence, the controller may mediate the data flow between the model and the view in both directions,which helps to more completely decouple the model from the view,and the controller may also provide the methods which effect the model's property changes for one or more views that are registered with it.

          ....Next,may be the two days after tomorrow ,I ll give a real example to explain this schema in details.......
          posted @ 2007-03-26 23:16 wqwqwqwqwq 閱讀(439) | 評(píng)論 (0)編輯 收藏
          這幾天忙忙亂亂的,也沒(méi)顧及這個(gè)blog,其實(shí)說(shuō)句實(shí)話(huà),自己也好幾天沒(méi)在研究技術(shù)的東西了,只是在看看IBM的一些個(gè)產(chǎn)品,哎~所以今天還是沒(méi)打算寫(xiě)寫(xiě)技術(shù),只是來(lái)post自己這幾天的一些瑣瑣碎碎。還算高興的事情是自己的小隊(duì)伍獲得了國(guó)際數(shù)學(xué)建模競(jìng)賽2等獎(jiǎng),雖然不是很理想,但自己還是滿(mǎn)足了,畢竟帶的娘子(當(dāng)然是除了我了)隊(duì)伍實(shí)力不是很強(qiáng),況且大過(guò)年的我原來(lái)的伙伴早飛回溫暖的南方了。其實(shí)我本身早厭倦了那種比賽,不過(guò)還是比較欣賞美國(guó)人的精明和對(duì)中國(guó)人明知故犯的無(wú)奈,也許吧,其實(shí)還是要慶祝一下自己的最后一次這種競(jìng)賽...
          這周學(xué)校組織無(wú)償獻(xiàn)血,雖然我并不在乎學(xué)校不給什么所謂的補(bǔ)償,我也不會(huì)因?yàn)楂I(xiàn)血怎么怎么的就有所目的,只是感覺(jué)這種行為還算是對(duì)社會(huì)作出了一點(diǎn)貢獻(xiàn)。最嶇奇的是導(dǎo)員居然不讓我獻(xiàn)血,當(dāng)然他的勸告算能讓我接受,但是自己還是很固執(zhí)的感覺(jué),無(wú)奈的導(dǎo)員也只好應(yīng)下了。哎~我這個(gè)人真是經(jīng)不起別人的勸告發(fā)現(xiàn),在好些個(gè)朋友的“嚇唬”下,終于作出了心虛的妥協(xié)...哎~,不過(guò)也算給我的母親一個(gè)很好的交代了。
          不說(shuō)這些令人掃興的話(huà)題了,還有一件好事,就是跟我關(guān)系很鐵的一個(gè)老師有了21個(gè)月的小寶寶,其實(shí)他才告訴我的,還是在網(wǎng)上。不過(guò)早應(yīng)該猜到了,因?yàn)檫@幾天就發(fā)現(xiàn)他“不誤正業(yè)”,整天不在辦公室,往家里一個(gè)勁的跑,不過(guò)在這里,雖然他不會(huì)知道,還是祝愿他博士論文順利通過(guò)吧,雙喜臨門(mén)...
          想早些休息了,Good night&& Good dream.
          posted @ 2007-03-22 23:18 wqwqwqwqwq 閱讀(445) | 評(píng)論 (0)編輯 收藏
          剛剛看看過(guò)魯豫有約的兩期節(jié)目,是采訪(fǎng)的年輕輕但身價(jià)過(guò)億的李想、高燃、戴志和茅侃侃。其實(shí),我并不因?yàn)樗麄兊哪贻p或是很有錢(qián),而感到任何詫異,但自己卻很欣常他們各自所持有的信念和創(chuàng)業(yè)過(guò)程中對(duì)資金的運(yùn)營(yíng)勇氣,我真的不知道隨著他們事業(yè)的增長(zhǎng)、社會(huì)的變更,他們還是否會(huì)是浪潮的寵兒、是否會(huì)和原來(lái)一樣,對(duì)待更多的運(yùn)營(yíng)資本同樣的保持清醒地頭腦,但我還是很祝福他們...

          看過(guò)之后,我的感觸很深,在這個(gè)社會(huì)上,或許是因?yàn)殡S著一個(gè)人學(xué)歷的漸漸增長(zhǎng),他也會(huì)變得懶惰,因?yàn)樗僖膊粫?huì)像社會(huì)地位很卑微的人一樣為生計(jì)擔(dān)心,我本也相信,人在骨子里是懶惰的。其實(shí),我自己也曾想過(guò),以后能找個(gè)比較大的外企工作,幾年之后一個(gè)月拿個(gè)幾W塊就ok了,然后就是一輩子平平淡淡的生活...:),或許我的思想還不夠先進(jìn)吧。他們的經(jīng)歷,也讓我重新思考,說(shuō)句實(shí)話(huà),其實(shí)他們并沒(méi)什么,只是在坎坷的社會(huì)中,為了自己的信念堅(jiān)持了下來(lái),并一直做到了現(xiàn)在。我想我也該在為別人打工的同時(shí),定位自己的目標(biāo),并堅(jiān)定的追求。高燃是我很佩服的一個(gè)人,完全是因?yàn)樗膱?zhí)著,無(wú)論是他考清華、追GirlFriend 還是去找投資人,最后到辦好公司。人的天賦很重要,但我還是更喜歡執(zhí)著...
          posted @ 2007-03-18 23:32 wqwqwqwqwq 閱讀(640) | 評(píng)論 (2)編輯 收藏
          Yestoday night,CA coordinator emailed and phoned me for Sunstudio running and test the ping-home function,I m sorry that I really didn't know what's this really mean under Unix,I am not sure,maybe about to edit the file of host,but I just ping -s localhost,well,maybe another ip destination.more awful,I cannot run the #./SUNWspro/bin/f95, #./SUNWspro/bin/cc, #./SUNWspro/bin/CC...I have sent the first test result,and continue to learn more about it,but I m really sorry.

           


           


          posted @ 2007-03-17 07:36 wqwqwqwqwq 閱讀(174) | 評(píng)論 (0)編輯 收藏
          The day before yestoday,I have received the intern offer letter from IBM CDL...to my surprise,cos of my little time,only can support 3-4ms.it's too absurd that when the assistant
          ask my IdCard num,well,God,I forgot it...:) During the time,not so along,exactly,only a few days ago,I met a manager in the IBM(BJ)CRL,She is a very kind person,also a manager(i think),she has recommended me to her colleagues,which I really thank her.so yestoday,these persons phoned me and asked if wanted to do some QA jobs,if though,they knew that i was admired by CDL.To the manners,I think today I should take their phone test though I will not accept their opportunity as to my promise to the CDL,That's important I think.
          Now I was a junior student,coming to realize that the campus life will be end,I was lucky I think,especailly about so many friends,can be ambassador of Sun Microsystems.lnc,can be a intern of IBM and so on.Now in my dream,hope that I can be a recommend student to get the master degree of tsingHua or BJUniversity this Sep.,then can go aboard for future research,last,back to the motherland to have a peace life,for which I will try my hard and best.
          posted @ 2007-03-16 12:19 wqwqwqwqwq 閱讀(469) | 評(píng)論 (0)編輯 收藏
          Maybe,u are tied of Windows and come to thinking of trying Linux,so many good Operation Systems,like,Suse Redhat ...or Novell have all enterprise u might need,as well,support communities.well,it's true enough--Solaris is also available and as a OpenSolaris form with AMD and Intel friends,with a pretty community going && more and more third-party supporting.U may download the Solaris form www.opentech.org.cn, www.opensolaris.org, ...Sun.
          I very like OpenSolaris not only its security,its creative,convinient...whereas,its all:).The Java Desktop is cool and we may also use click to operate,well,I like the terminal more.Now I use Solaris as a developer desktop,it integrates the Netbeans to develop Java which is also a excellent enviroment to develop others after u plug in,Sun Studio,a platform to develop C/C++ &&fortan,with sun compiler,efficient.If u think Solaris is too big and Enterprise-heavy,u will make a mistake,Solaris is very small but excellent perform,:),U can try urself.
          yestoday i make a techtalk about Sun openSolaris and Java,C/C++ development under it in my campus(DaLian University of Technology).To my surprise There were more students from the  disrelated computer science Department,more,even more girls.I saw a Linux teachers attending,I was very pleased,cos of Solaris is sure to attract the fancy of the Linux users,at least,It's better in my...our's eyes.:),as following I attach some of pics of my tech-talking to share with u.
             
          posted @ 2007-03-12 11:01 wqwqwqwqwq 閱讀(616) | 評(píng)論 (0)編輯 收藏
          僅列出標(biāo)題
          共10頁(yè): First 上一頁(yè) 2 3 4 5 6 7 8 9 10 下一頁(yè) 
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789




          常用鏈接

          留言簿(10)

          隨筆分類(lèi)(95)

          隨筆檔案(97)

          文章檔案(10)

          相冊(cè)

          J2ME技術(shù)網(wǎng)站

          java技術(shù)相關(guān)

          mess

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          校園夢(mèng)網(wǎng)網(wǎng)絡(luò)電話(huà),中國(guó)最優(yōu)秀的網(wǎng)絡(luò)電話(huà)
          主站蜘蛛池模板: 清水县| 大英县| 郸城县| 海晏县| 威信县| 厦门市| 得荣县| 南宫市| 米易县| 合水县| 潢川县| 云南省| 金堂县| 耒阳市| 山阳县| 科技| 剑河县| 陇南市| 兴业县| 漳平市| 义乌市| 民和| 大方县| 南漳县| 通榆县| 西吉县| 彭泽县| 新晃| 通江县| 图们市| 洛扎县| 泗洪县| 太白县| 中牟县| 阜城县| 临清市| 钦州市| 德兴市| 红原县| 长葛市| 六安市|