1 inline mode. The Derby database shares the same JVM with the application, typically the application is responsible for starting and stopping, not visible to other applications other than the application that started it, that is, other applications cannot access it;
List some key codes
Class.forName ("Org.apache.derby.jdbc.EmbeddedDriver"). newinstance ();//load driver Connection conn = Drivermanager.getconnection ("Jdbc:derby:testdb;create=true");//Connect database Statement st = Conn.createstatement (); St.execute ("CREATE Table User_info (ID INT not null,name VARCHAR (n) not NULL)");//Build Table St.executeupdate ("INSERT INTO User_i NFO (Id,name) VALUES (1, ' hermit ') ");//Insert data ResultSet rs = st.executequery (" SELECT * from User_info ");// Read the newly inserted data drivermanager.getconnection ("Jdbc:derby:;shutdown=true");//Close the database
Org.apache.derby.jdbc.EmbeddedDriver This driver is this D:\2tools\java\jdk1.7.0_17\db\lib\derby.jar
Can you see, no link account password, in the current directory will generate a file database folder TestDB
(The driver pack all said, play the time remember to join)
2 network mode. The Derby database exclusively has a JVM that runs as a standalone process on the server. In this mode, multiple applications are allowed to access the same derby database.
List some key codes
Class.forName ("Org.apache.derby.jdbc.ClientDriver"); Properties Properties = new properties ();p roperties.put ("Create", "true"); New database Connection conn = Drivermanager.getconnection ("Jdbc:derby://localhost:1527/myeclipse", properties);
Org.apache.derby.jdbc.ClientDriver This driver is this D:\2tools\java\jdk1.7.0_17\db\lib\derbyclient.jar
Can you see, do not need to link account password, can also write account password, there will be different circumstances, the reader himself pondering the
This article belongs to the small black _mo all, reprint please explain out http://my.oschina.net/moziqi/
Reference http://128kj.iteye.com/blog/1725848
(Java EE) summary about Derby Embedded mode and service mode