(Java EE) summary about Derby Embedded mode and service mode

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.