Derby???????????ü????
???????????? ???????[ 2014/5/21 11:09:12 ] ??????????????? ?????
????????
????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();
}
}
}
|
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11