????1. Derby ????
????????????С Derby ????????????????ɡ???????С???????????????????????????????????????????????????????
??????? Mysql ?????????????????????????
????Apache Derby?????????? java ??д???????Derby?????Open source??????
????Apache Derby???С??????????derby.jar???2M??????????????????????????????????????????ó???????á?
????????????????http://db.apache.org/derby/derby_downloads.html
???????????汾?У????? Build Environment ?????????????????? zip ??????????????ɡ?

????2. ?????????????????
????Derby ???? Java ??д???????????????? Java JRE?????尲??????ò?????
?????????? Derby ??????????????????????????????????????????????????????????г???
????Name:  DERBY_HOME
????Value: E:Javaderbydb-derby-10.10.1.1-bin
??????Path????%DERBY_HOME%in
??????CLASSPATH????%DERBY_HOME%lib derby.jar;%DERBY_HOME%libderbyclient.jar;%DERBY_HOME%libderbytools.jar;%DERBY_HOME%libderbynet.jar
?????е? cmd ??????棬?? sysinfo

?????????С??? Derby ????????????????????????????????????????????
????3. Derby ?????? Java ????
????a.????????????????????(??????????????????????????)
????connect 'jdbc:derby:dedb;user=root;password=root;create=true';
????b.??????????
????create table t_user(uuid varchar(32)?? name varchar(10)?? age int?? address varchar(40));
????c.?????Щ????????
????insert into t_user values('B82A6C5244244B9BB226EF31D5CBE508'?? 'Miachel'?? 20?? 'street 1');
????insert into t_user values('B82A6C5244244B9BB226EF31D5CBE509'?? 'Andrew'?? 35?? 'street 1');
????insert into t_user values('B82A6C5244244B9BB226EF31D5CBE510'?? 'Orson'?? 47?? 'street 1');
????insert into t_user values('B82A6C5244244B9BB226EF31D5CBE511'?? 'Rambo'?? 19?? 'street 1');
??????????? Derby ?????? ij ????(?? oracle ?? plus ????)??CMD ???????? ij ??????? ij ????
??????????????·????????? CMD ??·?????? C:UsersAdministrator> ?£??????? Derby ?????????????棻
?????????? sql ??????????????? derby ????κ?????
????d.?? Java ????????? Derby
import java.sql.*;
public class DerbyTest {
private static String driver = "org.apache.derby.jdbc.EmbeddedDriver";
private static String protocol = "jdbc:derby:";
String dbName = "E:\Users\Workspaces\Derby\dedb";
public static void loadDriver() {
try {
Class.forName(driver).newInstance();
} catch (Exception e) {
e.printStackTrace();
}
}
public void getDataFromDerby() {
try {
Connection conn = DriverManager.getConnection(protocol + dbName + ";user=root;password=root;create=true");
Statement statement = conn.createStatement();
ResultSet resultSet = statement.executeQuery("select * from t_user");
while (resultSet.next()) {
System.out.println(resultSet.getString(1));
System.out.println(resultSet.getString(2));
}
conn.close();
statement.close();
resultSet.close();
} catch (Exception e1) {
e1.printStackTrace();
}
}
public static void main(String[] args) {
DerbyTest derbyTest = new DerbyTest();
loadDriver();
derbyTest.getDataFromDerby();
}
}