import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public class MainClass {
public static void main(String[] args)
{
try {
String driver = “org.apache.derby.jdbc.EmbeddedDriver”;
Class.forName(driver).newInstance();
Connection conn = null;
conn = DriverManager.getConnection(“jdbc:derby:DerbyTestDB”);
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery(“SELECT city, state, zipcode FROM zipcodes”);
while(rs.next()) {
System.out.println(“City : “+ rs.getString(1));
System.out.println(“State : “+ rs.getString(2));
System.out.println(“Zipcode: “+ rs.getString(3));
System.out.println();
}
rs.close();
s.close();
conn.close();
} catch(Exception e) {
System.out.println(“Exception: “+ e);
e.printStackTrace();
}
}
}
Author: strong
Connect to Java DB (Derby) with org.apache.derby.jdbc.EmbeddedDriver
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
public class JavaDBDemo {
static Connection conn;
public static void main(String[] args) {
String driver = “org.apache.derby.jdbc.EmbeddedDriver”;
String connectionURL = “jdbc:derby:myDatabase;create=true”;
String createString = “CREATE TABLE Employee (NAME VARCHAR(32) NOT NULL, ADDRESS VARCHAR(50) NOT NULL)”;
try {
Class.forName(driver);
} catch (java.lang.ClassNotFoundException e) {
e.printStackTrace();
}
try {
conn = DriverManager.getConnection(connectionURL);
Statement stmt = conn.createStatement();
stmt.executeUpdate(createString);
PreparedStatement psInsert = conn.prepareStatement(“insert into Employee values (?,?)”);
psInsert.setString(1, args[0]);
psInsert.setString(2, args[1]);
psInsert.executeUpdate();
Statement stmt2 = conn.createStatement();
ResultSet rs = stmt2.executeQuery(“select * from Employee”);
int num = 0;
while (rs.next()) {
System.out.println(++num + “: Name: ” + rs.getString(1) + “\n Address” + rs.getString(2));
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
BEGIN and END Statements
mysql>
mysql> DELIMITER //
mysql> CREATE FUNCTION myProc (cost DECIMAL(10,2))
-> RETURNS DECIMAL(10,2)
->
-> SQL SECURITY DEFINER
->
-> tax: BEGIN
-> DECLARE order_tax DECIMAL(10,2);
-> SET order_tax = cost * .05;
-> RETURN order_tax;
-> END
-> //
Query OK, 0 rows affected (0.00 sec)
mysql> DELIMITER $$
mysql>
mysql> select myProc(123.45);
+—————-+
| myProc(123.45) |
+—————-+
| 6.17 |
+—————-+
1 row in set, 1 warning (0.00 sec)
mysql>
mysql> drop function myProc;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> DELIMITER //
mysql> CREATE FUNCTION myProc (cost DECIMAL(10,2))
-> RETURNS DECIMAL(10,2)
->
-> SQL SECURITY DEFINER
->
-> tax: BEGIN
-> DECLARE order_tax DECIMAL(10,2);
-> SET order_tax = cost * .05;
-> RETURN order_tax;
-> END
-> //
Query OK, 0 rows affected (0.00 sec)
mysql> DELIMITER $$
mysql>
mysql> select myProc(123.45);
+—————-+
| myProc(123.45) |
+—————-+
| 6.17 |
+—————-+
1 row in set, 1 warning (0.00 sec)
mysql>
mysql> drop function myProc;
Query OK, 0 rows affected (0.00 sec)
mysql>
Heatsoft Clone Cleaner Lite 清除電腦中無用的檔案複本
軟體:Heatsoft Clone Cleaner Lite(版本:1.05)
類別:檔案工具
性質:Freeware(1.4 M)

【編輯/何詩琦】
在網路族和上班族時常使用電腦來瀏覽網頁、文書處理時,自然而然經常產生內容類似或檔名類似的無用檔案複本,其中很可能是大量文件在經常複製修改而產生,也可能是網路下載的結果,想要一口氣把她們做個整理嗎?Heatsoft Clone Cleaner Lite 是個不錯的選擇。
第一次執行 Heatsoft Clone Cleaner Lite 的時候它會自動搜尋整個磁碟中的所有文件,不但是由檔名去判斷複本文件,它還會逐字比對內容,即使檔名差異很大但是事實上是差不多的文件也能被挑出來喔!然後的步驟就是讓使用者自己抉擇要刪除還是做整理、合併、複製、移動等動作。
但若是誤刪了重要系統檔或軟體必備元件怎麼辦?Heatsoft Clone Cleaner Lite 主視窗 Option 下 General 分頁中記得不要解除 Protect Windows folder 和 Protect idden folders 就不會刪到重要系統檔了。
下載:http://www.clonecleaner.com/HCCLITEheat.zip
Windows Live Writer 強大的 MSN Live 離線編寫工具
軟體:Windows Live Writer(版本:N/A)
類別:網頁編輯
性質:Freeware(1.7 M)

【編輯/何詩琦】
在越來越多人使用 Microsoft Live Space 之後,微軟又提出了部落格最佳編寫工具 ─ Windows Live Writer,它是主要用於 Live Space 或國外英文主流網站的部落格離線編輯軟體,不但功能強大而且操作簡單,對於 Blog 一族來說可是一大福音!
Windows Live Writer 當然也具備所見即所得的編輯介面,可以用拖拉方式直接新增本機的圖片、加入超連結、放置網路地圖、加入視訊影片,各樣功能應有盡有,而且重要的是,這些動作都能離線的狀態下完成,然後一口氣上傳,再也不需要心情記事寫到一半還等慢慢等待圖片上傳了。
在文字和圖像編輯的功能大致如同好用的網頁編輯工具,對於圖片大小、特效、文字內容效果等都可以做細部的編修,唯一比較稍嫌不足的是無法在 Windows Live Writer 編輯時直接點選加入 MSN 特有的可愛表情符號。
下載:http://g.live.com/1rebeta/zh-tw/WLInstaller.exe
Candy and Clyde 測試反應能力遊戲
軟體:Candy and Clyde(版本:N/A)
類別:動作遊戲
性質:Freeware()

【編輯/宗文】
遊戲中玩家必須依照關卡的指示,來完成規定的目標,如此才能順利過關。如果不能順利完成就會扣一生命值,等到扣光時遊戲就會結束。遊戲中玩家如能愈早完成關卡,則所獲得的積分將會愈高。遊戲關卡的內容包羅萬象,例如把火柴點燃燒掉照片、幫男孩擦拭眼淚、幫助怪獸用腳踏昆蟲或將相框扶正等等。遊戲中要完成關卡的時間很短,這將考驗玩家的反應能力,看看是否能在短時間內完成關卡。
隨著遊戲的進行,困難度會增高,例如餵魚的關卡原本只要餵兩隻,後面的關卡卻要餵三隻。而原本只要幫一位幫客撐雨傘到屋子裏,後面的關卡會變為兩位。因此愈後面的關卡,玩家的動作要愈快,否則很容易就會被扣一生命值。遊戲操控方面,利用滑鼠進行遊戲,有些需要點擊左鍵來完成關卡,有些是利用滑鼠迅速移動來達成,這些是依照關卡不同而採用不同的操作模式。

下載:http://www.miniclip.com/games/candy-and-clyde/en/
Sushi Go Round 迴轉壽司
軟體:Sushi Go Round(版本:N/A)
類別:動作遊戲
性質:Freeware()

【編輯/宗文】
遊戲中玩家將要經營一家迴轉壽司店,負責店裡面的所有工作。玩家要完成三個項目,分別是依據食譜來製作壽司、打電話來購買所需食材,與收拾顧客吃完壽司的盤子。遊戲中會有每天規定所要賺取的金額,玩家必須達成此目標,才能順利過關,再挑戰下一天經營壽司店的生活。反之沒達成目標,遊戲就會結束。
遊戲中玩家必須製作各種的壽司來滿足顧客的需求,那要如何製作出不同的壽司呢?首先玩家要注意顧客頭上會顯現出他們想吃的壽司圖樣,再來玩家可以翻開畫面下方的食譜,來查詢各種壽司的作法,看看需要哪些材料,再從左下角的食材區取出食材來製作壽司。取出食材時要小心,取錯數量或者種類時並不能反悔,而且製作出來的將是不能吃的便便!如此一來浪費金錢又浪費時間,這對於經營壽司店的玩家來講是很大的傷害。
當各種食材有不夠時,玩家必須利用畫面右下角的電話來通知購買,但是要有足夠的金錢才能購買。每次購買時又分為快速送達與一般的運送速度,此時玩家就要考量了,如果是一般的運送速度會較慢,但是可以省錢,而快速送達則要多花費錢,但是可以較快速來滿足顧客需求。

遊戲中顧客的頭上除了出現所要吃的壽司種類之外,還會有一排的五種小紅點,隨著等待壽司的時間,紅點會逐漸變成白點,這表示顧客愈等愈不耐煩,也快要生氣了,最後壽司還沒來的話,他們就會離開而不吃了。因此玩家應先滿足這些快要不耐煩的顧客。另外顧客吃完壽司後,玩家要記得收取盤子,這樣下一位客人才會上門,如果一直沒收拾將會損失許多的商機。

遊戲操控方面,利用滑鼠左鍵點取左下角的食材,他們會自動出現在竹廉上,等到所有食材準備完畢,再利用左鍵點擊一下竹廉,這樣就可以製作出壽司。用滑鼠左鍵點擊食譜,可以看到不同壽司所需要的食材,點擊電話可以購買不同食材。

下載:http://www.miniclip.com/games/sushi-go-round/en/
userfull editplus user file
HTML, ASP, PHP, Perl, VBScript, JavaScript, CSS, XML, XSLT, XSLT2, XML Schema, WML files
- jscript.zip (2007-05-10)
- JScript stx with Prototype.js – W. Jordan
- jscript.acp.zip (2007-05-10)
- JScript acp, ctl with Prototype.js – W. Jordan
- css.acp.zip (2007-05-10)
- CSS acp, ctl – W. Jordan
- asp_cs.zip (2007-05-10)
- ASP.net with C# acp, ctl – W. Jordan
- wsdl.zip (2007-04-05)
- WSDL stx – Derli Marcochi
- xslt2_acp.zip (2007-03-02)
- XSLT2 acp, ctl – W. Jordan
- xslt_acp.zip (2007-03-02)
- XSLT acp, ctl – W. Jordan
- ansi_meu.zip (2006-12-07)
- ASCII to HTML acp, ctl (Portuguese) – Armindo Lapa
- htmlbar3.zip (2006-12-04)
- HTML toolbar for HTML and XHTML updated – Kartros
- podcasting.zip (2006-06-16)
- Apple iPod iTunes Podcasting (RSS/XML).stx – Valerio Capello
- filezilla.zip (2006-06-13)
- FileZilla Settings file (XML) stx – Valerio Capello
- php514.zip (2006-05-08)
- PHP 5.1.4 stx – BiHon
- html_dotnet.zip (2006-04-27)
- Html with Asp.net ctl – dp-U-To Solutions
- css3.zip (2006-04-19)
- CSS stx – W. Jordan
- htmlbar2.zip (2006-03-30)
- HTML toolbar for HTML and XHTML – Martin “Shuster” Švec
- asp_net_20.zip (2006-03-21)
- ASP.NET (C#, ASP/ADO.NET, VB) ctl, template – Dimitrios Markatos
- php16.zip (2006-02-22)
- PHP stx – Julien Perez
- php5x.zip (2006-01-30)
- PHP 5.x stx – Will Buckner
- js5.zip (2005-11-17)
- JavaScript stx – Ze Thriller
- html_asp.zip (2005-11-15)
- HTML with ASP.net 2 Web Controls stx – W. Jordan
- asp_cs2.zip (2005-11-15)
- ASP.net with C# for .Net Framework 2 stx – W. Jordan
- dhtml.zip (2005-10-20)
- DHTML Events ctl – Daniel Guinn
- ant_2020.zip (2005-10-04)
- xml ANT (A Neat Tool) stx – Greg Presedo-Floyd
- csdoc.zip (2005-09-30)
- C# XML Documentation ctl – W. Jordan
- gps_xml.zip (2005-09-19)
- GPS xml (Google Earth KML XML, Geocaching XML, GPX XML) stx – Valerio Capello
- xul.zip (2005-08-27)
- XUL (XML-based User Interface Language) stx – rgv151
- php504.zip (2005-08-01)
- PHP 5.0.4 stx, acp – Bernhard Kirchen
- php.5.0.4.zip (2005-05-07)
- php 5.0.4 stx – Ilya V. Glazkov
- php_stx2.zip (2005-04-11)
- PHP 5.0.4 stx – Timofei Ivaschenko
- php-5.0.3.zip (2005-03-25)
- PHP 5.0.3 stx – Stoyan Dimitrov
- php_acp3.zip (2005-03-24)
- PHP acp – Iuri Carraro
- wsf2.zip (2004-08-27)
- Windows Script Host with JScript stx, acp – W. Jordan
- php503.zip (2005-01-08)
- PHP 5.0.3 stx – Seung Hwan Kang
Please use ‘Find’ command of your browser to search a file.
- plsql3.zip (2007-10-22)
- pl/sql Oracle’s procedure language stx – Mark Huber
- mysql3.zip (2007-07-30)
- MySQL 5.0 stx – Harry Long
- ms-tsql.zip (2007-06-04)
- Microsoft T-SQL 7.0 stx – Matthew Black
- java_1_6_0.zip (2007-02-06)
- Java SE 6 (1.6.0) stx – Тимофей Иващенко
- cpp_qt.zip (2006-11-21)
- C++ Qt 4.2.0/ANSI stx – Павел Спицин Валерьевич
- esql.zip (2006-11-20)
- ESQL for IBM Websphere Message Broker stx, acp – Sridar Swaminathan
- java.rar (2006-08-17)
- Java 2 SE Development Kit 5.0 (1.5.0) stx – Тимофей Иващенко
- sql4.zip (2006-03-20)
- SQL stx – George Alatrash
- cpp7.zip (2006-03-18)
- C++ stx (POSIX/ANSI/STL) – 임유빈 님
- velocity.zip (2006-02-01)
- Velocity for Java (*.vm) stx – Alon Halimi
- cs2.zip (2005-11-15)
- C# for .Net Framework 2 stx – W. Jordan
- java_1_4_2.zip (2005-10-10)
- Java 1.4.2 stx and Java syntax file generator software – Тим
- sql3.zip (2005-09-17)
- C/C++ with SQL stx – Marcos Moya
- dp_div.zip (2005-08-25)
- JavaScript ctl – dp-U-To Solutions
- mayacpp.zip (2005-08-04)
- C++ with Maya API class names stx – David Chen
- mysql2.zip (2005-07-23)
- MySQL stx – rgv151
- mobilec.zip (2005-06-07)
- Mobile C (GVM, GNEX) stx, acp – 이근수 님
- cpp_ctl.zip (2005-04-27)
- C++ ctl – Allen Varner 2005
- cpp_sym.zip (2005-03-23)
- C++ Programming for Symbian OS (Series 60) stx – Gaurav Jain
- plpg_postgre.zip (2004-11-23)
- PL/pgSQL and PostgreSQL (7.4.5) stx, acp – Tomek Jakubas
- dotnet11.zip (2005-01-19)
- C# with .Net Framework 1.1 stx – W. Jordan
- cpp8.zip (2005-01-18)
- C/C++ (enhanced) stx – Tim
Please use ‘Find’ command of your browser to search a file.
- masm615.zip (2007-10-12)
- MASM 6.15 stx – 吴文希
- as3.zip (2007-09-28)
- Flash ActionScript v2 + v3 stx, acp – Yoon js
- tcent2.zip (2007-09-19)
- Teamcenter enterprise stx, acp – Abhijit Patil
- as3.zip (2007-08-22)
- Flash ActionScript 3.0 / Flex 2.0 stx – mike
- skill.zip (2007-08-16)
- Cadence SKILL stx – Michael Moursalimov
- rhtml.zip (2007-08-09)
- Ruby HTML stx – Chris Bloom
- opensees.zip (2007-07-13)
- OpenSees (Open System for Earthquake Engineering Simulation) stx – Vagelis Plevris
- inform2.zip (2007-07-03)
- INFORM (interactive fiction development language) stx – Benjamin Lipovsek
- frm.zip (2007-07-02)
- ARM FRM(FileReadMaster) stx – Chao CHEN
- vhdl2.zip (2007-07-02)
- VHDL-200x stx – Chao CHEN
- verilog2.zip (2007-07-02)
- Verilog/SystemVerilog stx – Chao CHEN
- scope.zip (2007-06-25)
- FLIGHTLAB/Scope stx – Fahri Ersel OLCER
- rhapsody.zip (2007-06-09)
- Rhapsody v7.1 Property stx – Dean Andreakis
- powershell.zip (2007-05-28)
- Powershell stx – Alan Hockings
- autoit.zip (2007-05-17)
- AutoIt3 version 3.2.2.0 stx, ctl – Brett Pantalone
- r2.zip (2007-05-15)
- R programming language stx – Wei Wang
- yml.zip (2007-04-17)
- YAML (Ruby on Rails .yml file) stx – Tim Huffam
- evb.zip (2007-04-12)
- Envision Basic stx, acp – William Furr
- groovy.zip (2007-03-26)
- Groovy stx – Michal Szklanowski
- tms320_f24x.zip (2007-02-06)
- DSP C24X Texas Instruments TMS 320F24X stx – Lotfi
- nco_rules.zip (2007-02-03)
- Netcool rules stx – Aleks Mitrovic
- fbsl_stx.zip (2007-01-26)
- FBSL stx – Gérôme GUILLEMIN
- xilinx.zip (2007-01-15)
- Xilinx Picoblaze Assembler stx – Ahmed Zuhair Al-Wattar
- bash.zip (2007-01-04)
- Bash Script, Linux commands stx, acp, ctl – Chris Lam
How MySQL Optimises ORDER BY
How MySQL Optimises ORDER BY
In some cases MySQL can uses index to satisfy an ORDER BY or GROUP BY request without doing any extra sorting.
The index can also be used even if the ORDER BY doesn’t match the index exactly, as long as all the unused index parts and all the extra are ORDER BY columns are constants in the WHERE clause. The following queries will use the index to resolve the ORDER BY / GROUP BY part:
SELECT * FROM t1 ORDER BY key_part1,key_part2,…
SELECT * FROM t1 WHERE key_part1=constant ORDER BY key_part2
SELECT * FROM t1 WHERE key_part1=constant GROUP BY key_part2
SELECT * FROM t1 ORDER BY key_part1 DESC,key_part2 DESC
SELECT * FROM t1 WHERE key_part1=1 ORDER BY key_part1 DESC,key_part2 DESC
Some cases where MySQL can not use indexes to resolve the ORDER BY: (Note that MySQL will still use indexes to find the rows that matches the WHERE clause):
* You are doing an ORDER BY on different keys: SELECT * FROM t1 ORDER BY key1,key2
* You are doing an ORDER BY using non-consecutive key parts. SELECT * FROM t1 WHERE key2=constant ORDER BY key_part2
* You are mixing ASC and DESC. SELECT * FROM t1 ORDER BY key_part1 DESC,key_part2 ASC
* The key used to fetch the rows are not the same one that is used to do the ORDER BY: SELECT * FROM t1 WHERE key2=constant ORDER BY key1
* You are joining many tables and the columns you are doing an ORDER BY on are not all from the first not-const table that is used to retrieve rows (This is the first table in the EXPLAIN output which doesn’t use a const row fetch method).
* You have different ORDER BY and GROUP BY expressions.
* The used table index is an index type that doesn’t store rows in order. (Like the HASH index in HEAP tables).
In the cases where MySQL have to sort the result, it uses the following algorithm:
* Read all rows according to key or by table scanning. Rows that don’t match the WHERE clause are skipped.
* Store the sort-key in a buffer (of size sort_buffer).
* When the buffer gets full, run a qsort on it and store the result in a temporary file. Save a pointer to the sorted block. (In the case where all rows fits into the sort buffer, no temporary file is created)
* Repeat the above until all rows have been read.
* Do a multi-merge of up to MERGEBUFF (7) regions to one block in another temporary file. Repeat until all blocks from the first file are in the second file.
* Repeat the following until there is less than MERGEBUFF2 (15) blocks left.
* On the last multi-merge, only the pointer to the row (last part of the sort-key) is written to a result file.
* Now the code in `sql/records.cc’ will be used to read through them in sorted order by using the row pointers in the result file. To optimise this, we read in a big block of row pointers, sort these and then we read the rows in the sorted order into a row buffer (read_rnd_buffer_size) .
You can with EXPLAIN SELECT … ORDER BY check if MySQL can use indexes to resolve the query. If you get Using filesort in the extra column, then MySQL can’t use indexes to resolve the ORDER BY. See section 5.2.1 EXPLAIN Syntax (Get Information About a SELECT).
If you want to have a higher ORDER BY speed, you should first see if you can get MySQL to use indexes instead of having to do an extra sorting phase. If this is not possible, then you can do:
* Increase the size of the sort_buffer_size variable.
* Increase the size of the read_rnd_buffer_size variable.
* Change tmpdir to point to a dedicated disk with lots of empty space. If you use MySQL 4.1 or later you can spread load between several physical disks by setting tmpdir to a list of paths separated by colon : (semicolon ; on Windows). They will be used in round-robin fashion. Note: These paths should end up on different physical disks, not different partitions of the same disk.
By default, MySQL sorts all GROUP BY x,y[,…] queries as if you specified ORDER BY x,y[,…] in the query as well. If you include the ORDER BY clause explicitly, MySQL optimises it away without any speed penalty, though the sorting still occurs. If a query includes GROUP BY but you want to avoid the overhead of sorting the result, you can supress sorting by specifying ORDER BY NULL:
INSERT INTO foo SELECT a,COUNT(*) FROM bar GROUP BY a ORDER BY NULL;
Learning the Java Language
This trail covers the fundamentals of programming in the Java programming language.
Object-Oriented Programming Concepts teaches you the core concepts behind object-oriented programming: objects, messages, classes, and inheritance. This lesson ends by showing you how these concepts translate into code. Feel free to skip this lesson if you are already familiar with object-oriented programming.
Language Basics describes the traditional features of the language, including variables, arrays, data types, operators, and control flow.
Classes and Objects describes how to write the classes from which objects are created, and how to create and use the objects.
Interfaces and Inheritance describes interfaces—what they are, why you would want to write one, and how to write one. This section also describes the way in which you can derive one class from another. That is, how a subclass can inherit fields and methods from a superclass. You will learn that all classes are derived from the
Object
class, and how to modify the methods that a subclass inherits from superclasses.
Numbers and Strings This lesson describes how to use
Number
andString
objects The lesson also shows you how to format data for output.
Generics are a powerful feature of the Java programming language. They improve the type safety of your code, making more of your bugs detectable at compile time.
Packages are a feature of the Java programming language that help you to organize and structure your classes and their relationships to one another.