J2ME: Test the RMS listener methods
import java.io.*;import javax.microedition.midlet.*;import javax.microedition.rms.*;public class RmsListener extends MIDlet{ private RecordStore rs = null; static final String REC_STORE = “db_8”; public RmsListener() { // Open record store and add listener openRecStore(); rs.addRecordListener(new TestRecordListener()); // Initiate actions that will wake up the listener writeRecord(“J2ME and MIDP”); updateRecord(“MIDP and J2ME”); deleteRecord(); closeRecStore(); // Close record store deleteRecStore(); // Remove the record store } public void destroyApp( boolean unconditional ) { } public void startApp() { // There is no user interface, go ahead and shutdown destroyApp(false); notifyDestroyed(); } public void pauseApp() { } public void openRecStore() { try { // The second parameter indicates that the record store // should be created if it does not exist rs = RecordStore.openRecordStore(REC_STORE, true); } catch (Exception e) { db(e.toString()); } } public void closeRecStore() { try { rs.closeRecordStore(); } catch (Exception e) { db(e.toString()); } } public void deleteRecStore() { if (RecordStore.listRecordStores() != null) { try { RecordStore.deleteRecordStore(REC_STORE); } catch (Exception e) { db(e.toString()); } } } public void writeRecord(String str) { byte[] rec = str.getBytes(); try { rs.addRecord(rec, 0, rec.length); } catch (Exception e) { db(e.toString()); } } public void updateRecord(String str) { try { rs.setRecord(1, str.getBytes(), 0, str.length()); } catch (Exception e) { db(e.toString()); } } public void deleteRecord() { try { rs.deleteRecord(1); } catch (Exception e) { db(e.toString()); } } /*————————————————– * Simple message to console for debug/errors * When used with Exceptions we should handle the * error in a more appropriate manner. *————————————————-*/ public void db(String str) { System.err.println(“Msg: ” + str); }}/*————————————————–* Listen for updates to the record store*————————————————-*/class TestRecordListener implements RecordListener{ public void recordAdded(RecordStore recordStore, int recordId) { try { System.out.println(“Record with ID#: ” + recordId + ” added to RecordStore: ” + recordStore.getName()); } catch (Exception e) { System.err.println(e); } } public void recordDeleted(RecordStore recordStore, int recordId) { try { System.out.println(“Record with ID#: ” + recordId + ” deleted from RecordStore: ” + recordStore.getName()); } catch (Exception e) { System.err.println(e); } } public void recordChanged(RecordStore recordStore, int recordId) { try { System.out.println(“Record with ID#: ” + recordId + ” changed in RecordStore: ” + recordStore.getName()); } catch (Exception e) { System.err.println(e); } } }
J2ME : Record Enumeration Example
import javax.microedition.rms.*;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import java.io.*;public class RecordEnumerationExample extends MIDlet implements CommandListener{ private Display display; private Alert alert; private Form form; private Command exit; private Command start; private RecordStore recordstore = null; private RecordEnumeration recordEnumeration = null; public RecordEnumerationExample () { display = Display.getDisplay(this); exit = new Command(“Exit”, Command.SCREEN, 1); start = new Command(“Start”, Command.SCREEN, 1); form = new Form(“RecordEnumeration”); form.addCommand(exit); form.addCommand(start); form.setCommandListener(this); } public void startApp() { display.setCurrent(form); } public void pauseApp() { } public void destroyApp( boolean unconditional ) { } public void commandAction(Command command, Displayable displayable) { if (command == exit) { destroyApp(true); notifyDestroyed(); } else if (command == start) { try { recordstore = RecordStore.openRecordStore( “myRecordStore”, true ); } catch (Exception error) { alert = new Alert(“Error Creating”, error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { String outputData[] = {“First Record”, “Second Record”, “Third Record”}; for (int x = 0; x < 3; x++) { byte[] byteOutputData = outputData[x].getBytes(); recordstore.addRecord(byteOutputData, 0, byteOutputData.length); } } catch ( Exception error) { alert = new Alert(“Error Writing”, error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { StringBuffer buffer = new StringBuffer(); recordEnumeration = recordstore.enumerateRecords(null, null, false); while (recordEnumeration.hasNextElement()) { buffer.append(new String(recordEnumeration.nextRecord())); buffer.append(“\n”); } alert = new Alert(“Reading”, buffer.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } catch (Exception error) { alert = new Alert(“Error Reading”, error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { recordstore.closeRecordStore(); } catch (Exception error) { alert = new Alert(“Error Closing”, error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } if (RecordStore.listRecordStores() != null) { try { RecordStore.deleteRecordStore(“myRecordStore”); recordEnumeration.destroy(); } catch (Exception error) { alert = new Alert(“Error Removing”, error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } } } } }
J2ME : Store Database
import java.io.*;import javax.microedition.midlet.*;import javax.microedition.rms.*;public class TestStore extends MIDlet { static final String DBNAME = “mydata”; public TestStore() { RecordStore rs = null; // Data is persistent across MIDlet invocations. // So, first clear out the old record store… try { RecordStore.deleteRecordStore( DBNAME ); } catch( Exception e ){ // ignore any errors… } // Now create a new one and dump // each element out…. try { rs = RecordStore.openRecordStore( DBNAME, true ); byte[] data1 = “Here is the first record”.getBytes(); byte[] data2 = “And here is the second”.getBytes(); byte[] data3 = “And then the third”.getBytes(); data3[0] = 0; data3[data3.length-1] = (byte) –1; rs.addRecord( data1, 0, data1.length ); rs.addRecord( data2, 0, data2.length ); rs.addRecord( data3, 0, data3.length ); dumpRecordStore( rs, System.out ); rs.closeRecordStore(); } catch( RecordStoreException e ){ System.out.println( e ); } notifyDestroyed(); } public void dumpRecordStore( RecordStore rs, PrintStream out ) { if( rs == null ) return; StringBuffer hexLine = new StringBuffer(); StringBuffer charLine = new StringBuffer(); try { int lastID = rs.getNextRecordID(); byte[] data = new byte[100]; int size; for( int i = 1; i < lastID; ++i ){ try { size = rs.getRecordSize( i ); if( size > data.length ){ data = new byte[ size * 2 ]; } out.println( “Record ” + i + ” of size ” + size ); rs.getRecord( i, data, 0 ); dumpRecord( data, size, out, hexLine, charLine, 16 ); out.println( “” ); } catch( InvalidRecordIDException e ){ continue; } } } catch( RecordStoreException e ){ out.println( “Exception reading record store: ” + e ); } } private void dumpRecord( byte[] data, int size, PrintStream out, StringBuffer hexLine, StringBuffer charLine, int maxLen ) { if( size == 0 ) return; hexLine.setLength( 0 ); charLine.setLength( 0 ); int count = 0; for( int i = 0; i < size; ++i ){ char b = (char) ( data[i] & 0xFF ); if( b < 0x10 ){ hexLine.append( ‘0’ ); } hexLine.append( Integer.toHexString( b ) ); hexLine.append( ‘ ‘ ); if( ( b >= 32 && b <= 127 ) || Character.isDigit( b ) || Character.isLowerCase( b ) || Character.isUpperCase( b ) ){ charLine.append( (char) b ); } else { charLine.append( ‘.’ ); } if( ++count >= maxLen || i == size-1 ){ while( count++ < maxLen ){ hexLine.append( ” ” ); } hexLine.append( ‘ ‘ ); hexLine.append( charLine.toString() ); out.println( hexLine.toString() ); hexLine.setLength( 0 ); charLine.setLength( 0 ); count = 0; } } } public void destroyApp( boolean unconditional ) { } public void startApp() { } public void pauseApp() { }}
J2ME : Sort Record Example
import javax.microedition.rms.*;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import java.io.*;public class SortExample extends MIDlet implements CommandListener{ private Display display; private Alert alert; private Form form; private Command exit; private Command start; private RecordStore recordstore = null; private RecordEnumeration recordEnumeration = null; private Comparator comparator = null; public SortExample () { display = Display.getDisplay(this); exit = new Command(“Exit”, Command.SCREEN, 1); start = new Command(“Start”, Command.SCREEN, 1); form = new Form(“Mixed RecordEnumeration”, null); form.addCommand(exit); form.addCommand(start); form.setCommandListener(this); } public void startApp() { display.setCurrent(form); } public void pauseApp() { } public void destroyApp( boolean unconditional ) { } public void commandAction(Command command, Displayable displayable) { if (command == exit) { destroyApp(true); notifyDestroyed(); } else if (command == start) { try { recordstore = RecordStore.openRecordStore( “myRecordStore”, true ); } catch (Exception error) { alert = new Alert(“Error Creating”, error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { String outputData[] = {“Mary”, “Bob”, “Adam”}; for (int x = 0; x < 3; x++) { byte[] byteOutputData = outputData[x].getBytes(); recordstore.addRecord(byteOutputData, 0, byteOutputData.length); } } catch ( Exception error) { alert = new Alert(“Error Writing”, error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { StringBuffer buffer = new StringBuffer(); Comparator comparator = new Comparator(); recordEnumeration = recordstore.enumerateRecords( null, comparator, false); while (recordEnumeration.hasNextElement()) { buffer.append(new String(recordEnumeration.nextRecord())); buffer.append(“\n”); } alert = new Alert(“Reading”, buffer.toString() , null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } catch (Exception error) { alert = new Alert(“Error Reading”, error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { recordstore.closeRecordStore(); } catch (Exception error) { alert = new Alert(“Error Closing”, error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } if (RecordStore.listRecordStores() != null) { try { RecordStore.deleteRecordStore(“myRecordStore”); recordEnumeration.destroy(); } catch (Exception error) { alert = new Alert(“Error Removing”, error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } } } } }class Comparator implements RecordComparator{ public int compare(byte[] record1, byte[] record2) { String string1 = new String(record1), string2= new String(record2); int comparison = string1.compareTo(string2); if (comparison == 0) return RecordComparator.EQUIVALENT; else if (comparison < 0) return RecordComparator.PRECEDES; else return RecordComparator.FOLLOWS; }}
oracle里的常用命令
oracle里的常用命令 第一章:日志管理 1.forcing log switches sql> alter system switch logfile; 2.forcing checkpoints sql> alter system checkpoint; 3.adding online redo log groups sql> alter database add logfile [group 4] sql> (‘/disk3/log4a.rdo’,’/disk4/log4b.rdo’) size 1m; 4.adding online redo log members sql> alter database add logfile member sql> ‘/disk3/log1b.rdo’ to group 1, sql> ‘/disk4/log2b.rdo’ to group 2; 5.changes the […]
Oracle 的入门心得
oracle的体系太庞大了,对于初学者来说,难免会有些无从下手的感觉,什么都想学,结果什么都学不好,所以把学习经验共享一下,希望让刚刚入门的人对oracle有一个总体的认识,少走一些弯路。 一、定位 oracle分两大块,一块是开发,一块是管理。开发主要是写写存储过程、触发器什么的,还有就是用Oracle的Develop工具做form。有点类似于程序员,需要有较强的逻辑思维和创造能力,个人觉得会比较辛苦,是青春饭J;管理则需要对oracle数据库的原理有深刻的认识,有全局操纵的能力和紧密的思维,责任较大,因为一个小的失误就会down掉整个数据库,相对前者来说,后者更看重经验。 因为数据库管理的责任重大,很少公司愿意请一个刚刚接触oracle的人去管理数据库。对于刚刚毕业的年轻人来说,可以先选择做开发,有一定经验后转型,去做数据库的管理。当然,这个还是要看人个的实际情况来定。 二、学习方法 我的方法很简单,就是:看书、思考、写笔记、做实验、再思考、再写笔记 看完理论的东西,自己静下心来想想,多问自己几个为什么,然后把所学和所想的知识点做个笔记;在想不通或有疑问的时候,就做做实验,想想怎么会这样,同样的,把实验的结果记下来。思考和做实验是为了深入的了解这个知识点。而做笔记的过程,也是理清自己思路的过程。 学习的过程是使一个问题由模糊到清晰,再由清晰到模糊的过程。而每次的改变都代表着你又学到了一个新的知识点。 学习的过程也是从点到线,从线到网,从网到面的过程。当点变成线的时候,你会有总豁然开朗的感觉。当网到面的时候,你就是高手了 很多网友,特别是初学的人,一碰到问题就拿到论坛上来问,在问前,你有没有查过书,自己有没有研究过,有没有搜索一下论坛?这就叫思维惰性。由别人来回答你的问题,会让你在短时间内不费劲地弄懂这个知识点,然而通过自己的努力去研究它,不但会更深入的了解这个知识点,更重要的是在研究的过程会提高你解决问题和分析问题的能力。总的来说,没有钻研的学习态度,不管学什么东西,都不会成功的。 当然,初学的人很多时候是因为遇到问题时,无从下手,也不知道去哪里找资料,才会到论坛上提问题的。但我认为,在提问的时候,是不是可以问别人是如何分析这个问题?从哪里可以找到相关的资料?而不是这个问题的答案是什么?授人以鱼不如授人以渔。 下面我讲下我处理问题的过程 首先要知道oracle的官方网站:www.oracle.com 这里有oracle的各种版本的数据库、应用工具和权威的官方文档。其次,还要知道http://metalink.oracle.com/这里是买了oracle服务或是oracle的合作伙伴才可以进去的,里面有很多权威的解决方案和补丁。然后就是一些著名网站:asktom.oracle.com www.orafaq.net, www.dbazine.com。这里有很多经验之谈。 遇到问题了。如果是概念上的问题,第一时间可以找tahiti.oracle.com,这里会给你最详细的解释。如果在运行的过程中出了什么错误。可以去metalink看看。如果是想知道事务的处理的经验之谈。可以去asktom。当然。这里只是相对而言。 三、oracle的体系 oracle的体系很庞大,要学习它,首先要了解oracle的框架。在这里,简要的讲一下oracle的架构,让初学者对oracle有一个整体的认识。 1、物理结构(由控制文件、数据文件、重做日志文件、参数文件、归档文件、密码文件组成) 控制文件:包含维护和验证数据库完整性的必要信息、例如,控制文件用于识别数据文件和重做日志文件,一个数据库至少需要一个控制文件 数据文件:存储数据的文件 重做日志文件:含对数据库所做的更改记录,这样万一出现故障可以启用数据恢复。一个数据库至少需要两个重做日志文件 参数文件:定义Oracle 例程的特性,例如它包含调整SGA 中一些内存结构大小的参数 归档文件:是重做日志文件的脱机副本,这些副本可能对于从介质失败中进行恢复很必要。 密码文件:认证哪些用户有权限启动和关闭Oracle例程 2、逻辑结构(表空间、段、区、块) 表空间:是数据库中的基本逻辑结构,一系列数据文件的集合。 段:是对象在数据库中占用的空间 区:是为数据一次性预留的一个较大的存储空间 块:ORACLE最基本的存储单位,在建立数据库的时候指定 3、内存分配(SGA和PGA) SGA:是用于存储数据库信息的内存区,该信息为数据库进程所共享。它包含Oracle 服务器的数据和控制信息, 它是在Oracle […]
繁体版的WinXP操作系统
繁体版的WinXP操作系统,vol的,不用激活,其他的就不说了 下載地址
Joost - 網路電視不打烊
Joost - 網路電視不打烊軟體:Joost(版本:0.10.3)類別:網路多媒體性質:Freeware(9.7 M)【編輯/王國淵】近年來,由於網路建設發展迅速,使用者們家中所使用的網路已經由原本的數據機撥接、ADSL 、Cabel 進步到目前最新的 FTTB 了,隨著所使用的頻寬持續成長,許多的多媒體應用就能夠被透過網路來實現,而網路電視就是很好的一個例子。但是,要欣賞網路電視前,你當然要有一套合適的播放軟體囉,Joost 就是一款值得你一試選擇。Joost 是一款免費的網路電視軟體,使用者只要安裝之後,就可以透過它內建的選台器功能,選擇觀看數百個線上頻道,這麼多頻道數,可是沒有一家第四台業者比得上的喔。舉凡新聞、體育、電影、卡通,都可能在這包羅萬象的網路電視上找到,讓你想看什麼、就看什麼,再也不用擔心電視上撥的都是老舊又重複的節目或影片了。網路是無遠弗屆的,也因此,網路電視台的種類也是千奇百怪。而使用 Joost 的好處就是,它內建的節目頻道功能會不斷地擴充,讓你每天都有不同的選擇,永遠不會嫌膩。如果想要看看多元化的節目,甚至是想聽聽外語新聞,那麼 Joost 可是一個免費又方便的選擇喔!下載:http://www.joost.com/getjoost.html
[BT]Survivor_China_-_S15E01-03
Download Torrent: Survivor_China_-_S15E03_-_I_Lost_Two_Hands_And_Possibly_A_Shoulder_-_DieselTV_Divx[www.strongd.net].torrent Survivor_China_S15_Ep02-TGK_Team_Crazy_Cowboy[www.strongd.net].torrentSurvivor_China_S15_E01_BBUSAFFT_AVI[www.strongd.net].torrent
Concurrency Testing in JAVA Applications
Testing and optimizing Java code to handle concurrent activities is difficult without test automation. Even with test automation, being able to correlate the test activity from the client side to observations of thread, memory, object and database connection use on the server side is difficult at best. In this article, Frank Cohen describes methods for […]