上海齊著雲科技Java面試、筆試題__Java

來源:互聯網
上載者:User
1.notifyAll有什麼不好?
如果調用notify,多個線程中只會有一個線程從休眠轉入阻塞狀態,這個線程會參與爭奪那個被synchronized的資源,而如果調用notifyAll,那麼所有休眠的線程都會轉入阻塞狀態去爭奪資源。

2. java事務代碼的書寫
Class.forName("com.mysql.jdbc.Driver");    
try{  
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/dbtest", "root", "root");    
Statement stmt=con.createStatement();
System.out.println("開啟事務");    
con.setAutoCommit(false);  //關閉自動認可開啟事務
stmt.executeUpdate("insert into student values (’sw1’,’事務1’,’男’)");    
stmt.executeUpdate("insert into student values (’sw2’,’事務2’,’女’)");    
con.rollback();    
stmt.executeUpdate("insert into student values (’sw3’,’事務3’,’男’)");    
stmt.executeUpdate("insert into student values (’sw4’,’事務4’,’女’)");    
con.commit();  //如果你不提交那麼本次操作不會對資料庫造成任何    
System.out.println("事務提交");    
}catch(SQLException e){
System.out.println("資料庫操作出現異常");    
} 

3.自己用java實現觀察者模式
可參考:http://www.cnblogs.com/mengdd/archive/2013/02/07/2908929.html
java中Observable、Observer使用方法可參考
http://blog.csdn.net/hfhwfw/article/details/38044381

4. java中的SHA的使用
try{  
String msg = "hello world";  
System.out.println("明文是:" + msg);  
MessageDigest md5 = MessageDigest.getInstance("SHA");   
byte[] srcBytes = msg.getBytes();  
md5.update(srcBytes);   
byte[] resultBytes= md5.digest();  
String result = new String(resultBytes);  
System.out.println("密文是:" + result);  
String result1 = new String( Hex.encode(resultBytes));  
System.out.println("16進位密文是:" + result1);  
} catch( NoSuchAlgorithmException e){  
e.printStackTrace();  

}  

5. 業務資料每天有2tb解決方案

6. 結構化資料庫與非結構化資料庫
在資訊社會,資訊可以劃分為兩大類。一類資訊能夠用資料或統一的結構加以表示,我們稱之為結構化資料,如數字、符號;而另一類資訊無法用數字或統一的結構表示,如文本、映像、聲音、網頁等,我們稱之為非結構化資料。結構化資料屬於非結構化資料,是非結構化資料的特例。 
隨著網路技術的發展,特別是Internet和Intranet技術的飛快發展,使得非結構化資料的數量日趨增大。這時,主要用於管理結構化資料的關聯式資料庫的局限性暴露地越來越明顯。因而,資料庫技術相應地進入了“後關聯式資料庫時代”,發展進入基於網路應用的非結構化資料庫時代。所謂非結構化資料庫,是指資料庫的變長紀錄由若干不可重複和可重複的欄位組成,而每個欄位又可由若干不可重複和可重複的子欄位組成。簡單地說,非結構化資料庫就是欄位可變的資料庫。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.