public class testdb extends Object
This sample program is a minimal Java application showing JDBC access to a Derby database.
Instructions for how to run this program are given in example.html, by default located in the same directory as this source file ($DERBY_HOME/demo/programs/simple/).
Derby applications can run against Derby running in an embedded or a client/server framework.
When Derby runs in an embedded framework, the JDBC application and Derby run in the same Java Virtual Machine (JVM). The application starts up the Derby engine.
When Derby runs in a client/server framework, the application runs in a different JVM from Derby. The application only needs to load the client driver, and the connectivity framework (in this case the Derby Network Server) provides network connections.
Constructor and Description |
---|
testdb() |
Modifier and Type | Method and Description |
---|---|
static void |
main(String[] args)
Starts the demo by creating a new instance of this class and running the
go() method. |
static void |
printSQLException(SQLException e)
Prints details of an SQLException chain to
System.err . |
public static void main(String[] args)
Starts the demo by creating a new instance of this class and running the go()
method.
When you run this application, you may give one of the following arguments:
embedded
- default, if none specified. Will use Derby's embedded driver. This driver is
included in the derby.jar file.derbyclient
- will use the Derby client driver to access the Derby Network Server. This
driver is included in the derbyclient.jar file.
When you are using a client/server framework, the network server must already be running when trying to obtain
client connections to Derby. This demo program will will try to connect to a network server on this host (the
localhost), see the protocol
instance variable.
When running this demo, you must include the correct driver in the classpath of the JVM. See example.html for details.
args
- This program accepts one optional argument specifying which connection framework (JDBC driver) to use
(see above). The default is to use the embedded JDBC driver.public static void printSQLException(SQLException e)
System.err
. Details included are SQL State, Error
code, Exception message.e
- the SQLException from which to print details.Copyright © 2005–2017 Alfresco Software. All rights reserved.