Derby is a pure Java relational database engine using standard SQL and JDBC as its APIs
Download latest release of derby database from http://db.apache.org/derby/releases/
Download the zip version, Extract the zip file and set classpath to environment variables.
we can find, more details in the following link
http://db.apache.org/derby/docs/dev/adminguide/tadmincbdjhhfd.html
Use startNetworkServer command to run the derby database.
Hibernate Configuration
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">
org.hibernate.dialect.DerbyDialect
</property>
<property name="connection.url">
jdbc:derby://localhost:1527/
</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">
org.apache.derby.jdbc.ClientDriver
</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="EmpTO.hbm.xml" />
</session-factory>
</hibernate-configuration>
By default, the Derby Network Server only accepts requests from the localhost on port 1527
The following is the database connection URL syntax for Java DB:
Download latest release of derby database from http://db.apache.org/derby/releases/
Download the zip version, Extract the zip file and set classpath to environment variables.
Operating System | Command |
---|---|
Windows | set DERBY_HOME=C:\derby set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_24 set PATH=%DERBY_HOME%\bin;%PATH% startNetworkServer |
UNIX (Korn Shell) | export DERBY_HOME=/opt/derby export JAVA_HOME=/usr/j2se export PATH="$DERBY_HOME/bin:$PATH" startNetworkServer |
we can find, more details in the following link
http://db.apache.org/derby/docs/dev/adminguide/tadmincbdjhhfd.html
Use startNetworkServer command to run the derby database.
Hibernate Configuration
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">
org.hibernate.dialect.DerbyDialect
</property>
<property name="connection.url">
jdbc:derby://localhost:1527/
testdb
;create=true</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">
org.apache.derby.jdbc.ClientDriver
</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="EmpTO.hbm.xml" />
</session-factory>
</hibernate-configuration>
By default, the Derby Network Server only accepts requests from the localhost on port 1527
The following is the database connection URL syntax for Java DB:
jdbc:derby:[subsubprotocol:][databaseName][;attribute=value]*
subsubprotocol
specifies where Java DB should search for the database, either in a directory, in memory, in a class path, or in a JAR file. It is typically omitted.databaseName
is the name of the database to connect to.attribute=value
represents an optional, semicolon-separated list of attributes. These attributes enable you to instruct Java DB to perform various tasks, including the following:- Create the database specified in the connection URL.
- Encrypt the database specified in the connection URL.
- Specify directories to store logging and trace information.
- Specify a user name and password to connect to the database.
jdbc:derby:
//localhost:1527/
testdb;create=true
, where testdb
is the name of the database to connect to, and create=true
instructs the DBMS to create the database.
No comments :
Post a Comment