????????
????C:>ij
????ij ?汾 10.10
????ij> CONNECT 'jdbc:derby:D:ProjectderbyDB estdb;create=true';??????????testdb??????????????????
????ij> CONNECT 'jdbc:derby:D:ProjectderbyDB estdb;';           ??????testdb?????
????ij(CONNECTION1)> CREATE TABLE FIRSTTABLE(ID INT PRIMARY KEY??NAME VARCHAR(12));?????????
?????????/????/??? 0 ??
????ij(CONNECTION1)> INSERT INTO FIRSTTABLE VALUES(10??'TEN')??(20??'TWENTY')??(30??'THIRTY');???????????

?????????/????/??? 3 ??
????ij(CONNECTION1)> SELECT * FROM FIRSTTABLE;
????ID |NAME
????------------------------
????10 |TEN
????20 |TWENTY
????30 |THIRTY
????????? 3 ??
????ij(CONNECTION1)>exit;???????
???????
????1. sysinfo???????????Java?????????Derby??汾?????
????2. ij??????????????????????SQL????????????????????????
????????
????????????????????????γ????в???JavaDB

 

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;
public class TestDerby {
public static void main(String[] args) {
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
System.out.println("Load the embedded driver");
Connection conn = null;
Properties props = new Properties();
props.put("user"?? "user1"); props.put("password"?? "user1");
conn=DriverManager.getConnection("jdbc:derby:C:\Project\derbyDB\testdb;");
System.out.println("create and connect to testdb");
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM FIRSTTABLE");
System.out.println("name score");
while(rs.next()) {
StringBuilder builder = new StringBuilder(rs.getString(1));
builder.append(" ");
builder.append(rs.getInt(1));
System.out.println(builder.toString());
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}
}
}