Sun River
Topics about Java SE, Servlet/JSP, JDBC, MultiThread, UML, Design Pattern, CSS, JavaScript, Maven, JBoss, Tomcat, ...
posts - 78,comments - 0,trackbacks - 0
1. How do i find whether a parameter exists in the request object?(JSP)
A:   boolean hasPara=request.getParameterMap().contains(theParameter);
     or boolean hasfoo=!(request.getParameter("foo")==null || request.getParameter("foo").equals(""))
2. What is 2 phase commit?
 A: It is an algorithm used to ensure the integrity of a committing transaction. In Phase 1, the transaction coordinator contacts potential participants in the transaction, the participants all agree to make the results of the transaction permanent but do not do so immediately. The participants log information to disk to ensure they can complete in phase 2. if all the participants agree to commit, the coordinator logs that agreement and the outcome is decided. The recording of this agreement in the log ends in Phase 2, thecoordinator informs each participant of the decision, and they permanently update their resources.
3. How Can I insert images into a MySql Database?
 A:   
           File file=new File(fPic);
           FileInputStream fis=new FileInputStream(file);
           PreparedStatement ps=con.prepareStatement("insert into dbPic values(?,?)");  
           ps.setString(1,file.getName());
           ps.setBinaryStream(2,fis,(int)file.length());
           ps.executeUpdate();
           ps.close();
           fis.close();
posted on 2006-09-25 06:43 Sun River 阅读(276) 评论(0)  编辑  收藏