<!-- <questionid="arch-overall"when="init"> Describetheoverallarchitecture. <hint> WhatwillbeAPIfor <ahref="http://openide.netbeans.org/tutorial/api-design.html#design.apiandspi"> clientsandwhatsupportAPI</a>? Whatpartswillbepluggable? Howwillplug-insberegistered?Pleaseuse<code><apitype="export"/></code> todescribeyourgeneralAPIs. Ifpossiblepleaseprovide simplediagrams. </hint> </question>
-->
<answer id="arch-overall">
<p>
The Database module provides the
<api group="java" name="DatabaseExplorerAPI"type="export" category="official"url="@TOP@index.html"/>
which allows access to the database connections and drivers
defined in the Database Explorer. It allows a client to retrieve the
connection list and their properties, to create new connections and remove
existing ones. The Database Explorer also manages a list of JDBC drivers used to
connect to databases. The API provides access to these drivers and allows
to create new and remove existing drivers.
</p>
<p>
The <api group="layer" name="DatabaseExplorerLayerAPI"type="export" category="official"url="@TOP@index.html"/>
allows for the declarative registration of database connections and JDBC
drivers in the module layer. Database runtimes (which are representations of
an instance of a database server) can also be registered in the layer.
</p> <!-- TheActionsfolderfordbschemaandsqlfiles.Theyshouldactuallybeindb/modelanddb/core,but thosemodulesdon'thaveJavadoc,thereforethedescriptionishere.
-->
<p>
<api group="layer" name="Loaders-text-dbschema-Actions"type="export" category="devel"url="@TOP@index.html"/>
allows extending <code>.dbschema</code> files with own actions by registering them in the
<code>Loaders/text/x-dbschema/Actions</code> folder. Note that this folder is actually provided by the
<code>org-netbeans-modules-dbschema.jar</code> module.
</p>
<p>
<api group="layer" name="Loaders-text-sql-Actions"type="export" category="devel"url="@TOP@index.html"/>
allows extending <code>.sql</code> files with own actions by registering them in the
<code>Loaders/text/x-sql/Actions</code> folder. Note that this folder is actually provided by the
<code>org-netbeans-modules-db-core.jar</code> module.
</p>
<p>
This module also provides a <api group="java" name="SQLSupportAPI"type="export"
category="official"url="@TOP@org/netbeans/api/db/sql/support/package-summary.html"/>
which provides utilities for working with SQL such as quoting identifiers.
</p>
</answer>
<!-- <questionid="arch-quality"when="init"> Howwillthe<ahref="http://www.netbeans.org/community/guidelines/q-evangelism.html">quality</a> ofyourcodebetestedand howarefutureregressionsgoingtobeprevented? <hint> Whatkindoftestingdo youwanttouse?Howmuchfunctionality,inwhichareas, shouldbecoveredbythetests? </hint> </question>
-->
<answer id="arch-quality">
<p>
All Javadoc-specified functionality should be covered by unit tests.
</p>
</answer>
<!-- <questionid="arch-time"when="init"> Whatarethetimeestimatesofthework? <hint> Pleaseexpressyourestimatesofhowlongthedesign,implementation, stabilizationarelikelytolast.Howmanypeoplewillbeneededto implementthisandwhatistheexpectedmilestonebywhichtheworkshouldbe ready? </hint> </question>
-->
<answer id="arch-time">
<p>
Most code is already written. About 5 man-days are still needed
for the registration of database runtimes and cleanups
and about two weeks shall be spent writing tests. The milestone by which
this API should be stable is promo-G.
</p>
</answer>
<!-- <questionid="arch-usecases"when="init"> <hint> Contentofthisanswerwillbedisplayedaspartofpageat http://www.netbeans.org/download/dev/javadoc/usecases.html Youcanusetags<usecasename="name>regularhtmldescription</usecase> andifyouwanttouseanURLyoucanprefixifwith@TOP@tobegin attherootofyourjavadoc </hint> Describethemain<ahref="http://openide.netbeans.org/tutorial/api-design.html#usecase"> usecases</a>ofthenewAPI.Whowilluseitunder whatcircumstances?Whatkindofcodewouldtypicallyneedtobewritten tousethemodule? </question>
-->
<answer id="arch-usecases">
<usecase id="register-drivers" name="Registering JDBC ../db.drivers">
<p>
An external module can register JDBC drivers. A typical example is a module
which provides integration with a database server. In this case the module
contains the JDBC driver for that database server and uses the Database
Explorer API to add it do the Database Explorer.
</p>
<p>
Another client of this API could be a module providing integration with a J2EE
application server. Sometimes a J2EE application server bundles a database server
for improving the out-of-the-box experience. When the server is registered
in the IDE the JDBC drivers for the bundled database server are added to the Database
Explorer.
</p>
<p>
The drivers are registered by making calls on
<a href="@TOP@org/netbeans/api/db/explorer/JDBCDriverManager.html">JDBCDriverManager</a> or
by registering an XML file which describes the driver in the module layer.
The XML file is described by the
<a href="http://www.netbeans.org/dtds/jdbc-driver-1_1.dtd">JDBC Driver DTD</a>.
An example of a registration file describing the JDBC driver for PostgreSQL follows:
</p>
<pre>
<?xmlversion='1.0'?>
<!DOCTYPE driver PUBLIC'-//NetBeans//DTD JDBC Driver 1.0//EN''http://www.netbeans.org/dtds/jdbc-driver-1_0.dtd'>
<driver>
<name value='postgresql-7'/>
<display-name value='PostgreSQL (v7.0 and later)'/>
<class value='org.postgresql.Driver'/>
<urls>
<url value='file:/folder1/folder2/drivers/pg74.1jdbc3.jar'/>
</urls>
</driver>
</pre>
<p>
This file should be registered in the <code>Databases/JDBCDrivers</code> folder of the module layer.
To addres a bundled JAR inside the IDE the nbinst protocol can be used in the URLs:
<code>nbinst:/modules/ext/bundled-driver.jar</code>.
</p>
</usecase>
<usecase id="get-jdbc-driver" name="Get the underlying JDBC Driver instance for a JDBCDriver">
<p>
You can use the <a href="@TOP@org/netbeans/api/db/explorer/JDBCDriver.html#getDriver()">JDBCDriver.getDriver()</a>
method to obtain a reference to the underlying JDBC Driver instance. This is useful if you want to use the registered
drivers but create your own JDBC connections independent of the Database Explorer.
</p>
</usecase>
<usecase id="retrieve-drivers" name="Retrieving the list of JDBC ../db.drivers">
<p>
When creating a new connection the JDBC driver which it should use can be specified.
A list of all the registered JDBC drivers can be retrieved using
<a href="@TOP@org/netbeans/api/db/explorer/JDBCDriverManager.html#getDrivers()">JDBCDriverManager.getDrivers()</a>.
</p>
</usecase>
<usecase id="register-runtimes" name="Registering database runtimes">
<p>
An external module can register new database runtimes. A database runtime
is an abstraction of a database server instance
(usually bundled with the IDE, an integration module or with a J2EE server). It allows a database
server instance to be started and stopped when a connection to this
instance is made in the IDE. Database runtimes are represented by the
<a href="@TOP@org/netbeans/spi/db/explorer/DatabaseRuntime.html">DatabaseRuntime</a>
SPI interface and are registered in the <code>Databases/Runtimes</code> of the module layer.
</p>
</usecase>
<usecase id="create-connections" name="Creating database connections">
<p>
A module can create new database connections (for example to a bundled database).
New connections can be added by calling
<a href="@TOP@org/netbeans/api/db/explorer/DatabaseConnection.html#create(org.netbeans.api.db.explorer.JDBCDriver,java.lang.String,java.lang.String,java.lang.String,java.lang.String,boolean)">DatabaseConnection.create()</a>
to create a new DatabaseConnection instance and then
<a href="@TOP@org/netbeans/api/db/explorer/ConnectionManager.html#addConnection(org.netbeans.api.db.explorer.DatabaseConnection)">ConnectionManager.addConnection()</a> to
add the connection to the Database Explorer.
</p>
<p>
New connections can also be added by registering them in the module layer.
The format of the registration file is described by the
<a href="http://www.netbeans.org/dtds/connection-1_0.dtd">Database Connection DTD</a>.
An example of a registration file describing a connection to a PostgreSQL database follows:
</p>
<pre>
<?xmlversion='1.0'?>
<!DOCTYPE connection PUBLIC'-//NetBeans//DTD Database Connection 1.1//EN''http://www.netbeans.org/dtds/connection-1_1.dtd'>
<connection>
<driver-class value='org.postgresql.Driver'/>
<driver-name value='postgres-7'/>
<database-url value='jdbc:postgresql:test'/>
<schema value='public'/>
<user value='test'/>
<password value='cGFzc3dvcmQ='/>
</connection>
</pre>
<p>
This file should be registered in the <code>Databases/Connections</code> folder
of the module layer.
</p>
<p>
The password element is optional, but if it is included,
its value must be the Base64 encoding of the UTF-8 representation of the
password. Note that the UTF-8 representation of passwords composed entirely of
ASCII characters is the same as their ASCII representation, so for such
passwords all that needs to be done is to convert them to Base64.
</p>
<p>
Base64 encoding serves as a simple scrambling to prevent
accidental revelation of the password. It is not indended to offer any
real security. You can protect the password by assigning appropriate
file protections to the connection XML file.
</p>
</usecase>
<usecase id="retrieve-connections" name="Retrieving and displaying the list of database connections">
<p>
Sometimes the list of connections needs to be displayed somewhere
else in the IDE than the Runtime tab. A typical example is the SQL Editor,
which allows the user to select the database connection which the SQL statement
will be executed against in a combo box in the editor toolbar.
The list of connections can be obtained by calling
<a href="@TOP@org/netbeans/api/db/explorer/ConnectionManager.html#getConnections()">ConnectionManager.getConnections()</a>,
which returns an array of
<a href="@TOP@org/netbeans/api/db/explorer/DatabaseConnection.html">DatabaseConnection</a>
instances.
</p>
<p>
The client usually needs to show the display name of the connection. The display name can be retrieved using the
<a href="@TOP@org/netbeans/api/db/explorer/DatabaseConnection.html#getDisplayName()">DatabaseConnection.getDisplayName()</a>
method.
</p>
</usecase>
<usecase id="retrieve-connection-props" name="Retrieving the properties of database connections">
<p>
Sometimes a client needs to retrieve the connection properties, such as the driver class.
An example could be a module for a J2EE server creating a connection pool. The properties can
be retrieved using the <code>getDriverClass()</code>, <code>getDatabaseURL()</code>,
<code>getSchema()</code>, <code>getUser()</code> and <code>getPassword()</code>
methods of the
<a href="@TOP@org/netbeans/api/db/explorer/DatabaseConnection.html">DatabaseConnection</a>
class.
</p>
</usecase>
<usecase id="new-connection" name="Showing the New Database Connection dialog">
<p>
Usually when displaying a list of connections (usually in a combo box),
the last item is "New Connection", which displays the standard New Database Connection
dialog of the Database Explorer. This can be achieved by calling one of the
<a href="@TOP@org/netbeans/api/db/explorer/ConnectionManager.html#showAddConnectionDialog(org.netbeans.api.db.explorer.JDBCDriver)">ConnectionManager.showAddConnectionDialog()</a> methods.
</p>
</usecase>
<usecase id="remove-connection" name="Remove a database connection">
<p>
A user of this API may want to remove a connection from the list of connections
registered by the Database Explorer. This is done using
<a href="@TOP@org/netbeans/api/db/explorer/ConnectionManager.html#removeConnection(org.netbeans.api.db.explorer.DatabaseConnection)">ConnectionManager.removeConnection()</a>
</p>
</usecase>
<usecase id="connect-database" name="Connecting to a database">
<p>
A component which provides database functionality (such as the SQL Editor)
will need to connect to a database. This can be achieved using the
<a href="@TOP@org/netbeans/api/db/explorer/ConnectionManager.html#showConnectionDialog(org.netbeans.api.db.explorer.DatabaseConnection)">DatabaseConnection.showConnectionDialog()</a>
method and the <code>java.sql.Connection</code> instance can be retrieved using the
<a href="@TOP@org/netbeans/api/db/explorer/DatabaseConnection.html#getJDBCConnection()">getJDBCConnection()</a>
method.
</p>
<p>
If you want to connect to the database without showing a dialog or any kind of UI, you can use the
<a href="@TOP@org/netbeans/api/db/explorer/ConnectionManager.html#connect(org.netbeans.api.db.explorer.DatabaseConnection)">DatabaseConnection.connect()</a>
method.
</p>
</usecase>
<usecase id="test-connection" name="Test a database connection for validity">
<p>
You may want to test to make sure the underlying physical JDBC connection
obtained from a DatabaseConnection is either valid or null. This is done using the
<a href="@TOP@org/netbeans/api/db/explorer/DatabaseConnection.html#getJDBCConnection(boolean)">
DatabaseConnection.getJDBCConnection(boolean test)</a>
method, which validates the underlying connection before returning it. If the
connection is invalid, it marks the DatabaseConnection as disconnected and returns null.
</p>
</usecase>
<usecase id="connections-combo-box" name="Displaying the database connections in the UI">
<p>
A component which provides database functionality (such as the SQL Editor
or a module providing support for data sources) will need to let the user
select the a database connection, usually through a combo box.
This can be achieved using the
<a href="@TOP@org/netbeans/api/db/explorer/support/DatabaseExplorerUIs.html#connect(javax.swing.JComboBox,org.netbeans.api.db.explorer.ConnectionManager)">DatabaseExplorerUIs.connect()</a>
method. The <code>JComboBox</code> passed to the method will be filled with the list of connections as returned by
<a href="@TOP@org/netbeans/api/db/explorer/ConnectionManager.html#getConnections()">ConnectionManager.getConnections()</a>, followed by a separator
and a <em>New Database Connection</em> item which will display the dialog for adding a new database connection when selected.
</p>
</usecase>
<usecase id="metadata-transfer" name="Drag and drop support for database objects">
<p>
A component might need to allow database tables from the Database Explorer to
be dragged to a visual editor. An API is provided in <code>DatabaseMetaDataTransfer</code>
containing <code>DataFlavor</code>s for database objects and nested classes
encapsulating those database objects during a drag and drop transfer.
</p>
</usecase>
<usecase id="sql-identifier-support" name="Get support for working with SQL identifiers">
<p>
A component might need support for working with SQL identifiers. In particular,
it's important to know when to quote a SQL identifier. The
<a href="@TOP@org/netbeans/api/db/sql/support/SQLIdentifiers.Quoter.html">
SQLIdentifiers.Quoter</a> class is provided for this.
</p>
</usecase>
</answer>
<!-- <questionid="arch-what"when="init"> Whatisthisprojectgoodfor? <hint> Pleaseprovidehereafewlinesdescribingtheproject, whatproblemitshouldsolve,providelinkstodocumentation, specifications,etc. </hint> </question>
-->
<answer id="arch-what">
<p>
This project provides access to objects defined in the Database Explorer.
Documentation is available in the Javadoc.
</p>
</answer>
<!-- <questionid="compat-version"when="impl"> Canyourmodulecoexistwithearlierandfuture versionsofitself?Canyoucorrectlyreadalloldsettings?Willfuture versionsbeabletoreadyourcurrentsettings?Canyouread orpolitelyignoresettingsstoredbyafutureversion? <hint> Veryhelpfulforreadingsettingsistostoreversionnumber there,sofutureversionscandecidewhetherhowtoread/convert thesettingsandolderversionscanignorethenewones. </hint> </question>
-->
<answer id="compat-version">
<p>
The module can read old settings, but doesn't store version numbers.
</p>
</answer>
<!-- <questionid="dep-jre"when="final"> WhichversionofJREdoyouneed(1.2,1.3,1.4,etc.)? <hint> Itisexpectedthatifyourmodulerunson1.xthatitwillrun on1.x+1ifno,statethatplease.Alsodescribeherecaseswhere yourundifferentcodeondifferentversionsofJREandwhy. </hint> </question>
-->
<answer id="dep-jre">
<p>
The module runs on JRE 1.4 and higher.
</p>
</answer>
<!-- <questionid="deploy-jar"when="impl"> DoyoudeployjustmoduleJARfile(s)orotherfilesaswell? <hint> UsuallyamoduleconsistofoneJARfile(perhapswithClass-Path extensions)andalsoaconfigurationfilethatenablesit.Ifyou haveanyotherfiles,use <apigroup="java.io.File"name="yourname"type="export"category="friend"&an>gt;...</api> todefinethelocation,nameandstabilityofyourfiles(ofcourse changing"yourname"and"friend"tosuityourneeds). IfitusesmorethanoneJAR,describewheretheyarelocated,how theyrefertoeachother. IfitconsistofmoduleJAR(s)andotherfiles,pleasedescribe whatistheirpurpose,whyotherfilesarenecessary.Please makesurethatinstallation/uninstallationleavesthesystem instateasitwasbeforeinstallation. </hint> </question>
-->
<answer id="deploy-jar">
<p>
There are two JAR files: the module JAR file modules/org-netbeans-modules-db.jar
and a library used by the module located at modules/ext/ddl.jar.
</p>
</answer>
<!-- <questionid="exec-classloader"when="impl"> Doesyourcodecreateitsownclassloader(s)? <hint> Abitunusual.Pleaseexplainwhyandwhatfor. </hint> </question>
-->
<answer id="exec-classloader">
<p>
A class loader is created for loading JDBC drivers.
</p>
</answer>
<!-- <questionid="exec-threading"when="impl"> Whatthreadingmodels,ifany,doesyourmoduleadhereto? <hint> IfyourmodulecallsforeignAPIswhichhaveaspecificthreadingmodel, indicatehowyoucomplywiththerequirementsformultithreadedaccess (synchronization,mutexes,etc.)applicabletothoseAPIs. IfyourmoduledefinesanyAPIs,orhascomplexinternalstructures thatmightbeusedfrommultiplethreads,declarehowyouprotect dataagainstconcurrentaccess,raceconditions,deadlocks,etc., andwhethersuchrulesareenforcedbyruntimewarnings,errors,assertions,etc. Examples:aclassmightbenon-thread-safe(likeJavaCollections);might befullythread-safe(internallocking);mightrequireaccessthroughamutex (andmayormaynotautomaticallyacquirethatmutexonbehalfofaclientmethod); mightbeabletorunonlyintheeventqueue;etc. Alsodescribewhenanyeventsarefired:synchronously,asynchronously,etc. Ideas:<ahref="http://core.netbeans.org/proposals/threading/index.html#recommendations">ThreadingRecommendations</a>(inprogress) </hint> </question>
-->
<answer id="exec-threading">
<p>
The API is thread-safe. Most methods are not required to run on the event queue (although
the implementation of methods which display an UI switches to the event thread where necessary).
The methods which are required to run on the event queue say so in the
Javadoc and exceptions are thrown if this condition does not hold.
Events are fired synchronously.
</p>
</answer>
<!-- <questionid="format-clipboard"when="impl"> Whichdataflavors(ifany)doesyourcodereadfromorinsertto theclipboard(byaccesstoclipboardonmeanscallingmethodson<code>java.awt.datatransfer.Transferable</code>? <hint> OftenNode'sdealwithclipboardbyusageof<code>Node.clipboardCopy,Node.clipboardCutandNode.pasteTypes</code>. Checkyourcodeforoverridingthesemethods. </hint> </question>
-->
<answer id="format-clipboard">
<p>
Implementations of PasteType representing database tables and indexes are placed on the clipboard.
</p>
</answer>
<!-- <questionid="format-types"when="impl"> Whichprotocolsandfileformats(ifany)doesyourmodulereadorwriteondisk, ortransmitorreceiveoverthenetwork?Doyougenerateanantbuildscript? Canitbeeditedandmodified? <hint> <p> Filescanbereadandwrittenbyotherprograms,modulesandusers.Iftheyinfluence yourbehaviour,makesureyoueitherdocumenttheformatorclaimthatitisaprivate api(usingthe<api>tag). </p> <p> Ifyougenerateanantbuildfile,thisisverylikelygoingtobeseenbyendusersand theywillbeattemptedtoeditit.Youshouldbereadyforthatandprovideherealink todocumentationthatyouhaveforsuchpurposesandalsodescribehowyouaregoingto understandsuchfilesduringnextrelease,whenyou(verylikely)slightlychangethe format. </p> </hint> </question>
-->
<answer id="format-types">
<p>
The database connections, JDBC drivers and database runtimes are saved as XML files whose
DTDs are published.
</p>
</answer>
<!-- <questionid="lookup-lookup"when="init"> Doesyourmoduleuse<code>org.openide.util.Lookup</code> oranysimilartechnologytofindanycomponentstocommunicatewith?Whichones? <hint> Pleasedescribetheinterfacesyouaresearchingfor,where aredefined,whetheryouaresearchingforjustoneormoreofthem, iftheorderisimportant,etc.Alsoclassifythestabilityofsuch APIcontract.Forthatuse<apigroup=&lookup&/>tag. </hint> </question>
-->
<answer id="lookup-lookup">
<p>
FolderLookup is used to locate database runtimes. The
Databases/Runtimes folder in the default filesystem is searched for implementations
of the <code>DatabaseRuntime</code> interface.
</p>
</answer>
<!-- <questionid="perf-mem"when="final"> Howmuchmemorydoesyourcomponentconsume?Estimate witharelationtothenumberofwindows,etc. </question>
-->
<answer id="perf-mem">
<p>
A small amount of memory is necessary for the database connections, drivers and
runtimes. The amount of memory needed for displaying the structure of a
database is directly proportional to the number of elements in the database.
</p>
</answer>
<!-- <questionid="perf-progress"when="final"> Doesyourmoduleexecuteanylong-runningtasks? <hint>Longrunningtasksshouldneverblock AWTthreadasitbadlyhurtstheUI <ahref="http://performance.netbeans.org/responsiveness/issues.html"> responsiveness</a>. Taskslikeconnectingover network,computinghugeamountofdata,compilation bedoneasynchronously(forexample using<code>RequestProcessor</code>),definitivelyitshould notblockAWTthread. </hint> </question>
-->
<answer id="perf-progress">
<p>
Yes, any database call can be a long-running task. However, these calls are not executed in the
event thread.
</p>
</answer>
<!-- <questionid="perf-scale"when="init"> Whichexternalcriteriainfluencetheperformanceofyour program(sizeoffileineditor,numberoffilesinmenu, insourcedirectory,etc.)andhowwellyourcodescales? <hint> Pleaseincludesomeestimates,thereareothermoredetailed questionstoanswerinlaterphasesofimplementation. </hint> </question>
-->
<answer id="perf-scale">
<p>
Performance scales linearly with the number of connections and ../db.drivers,
but usually the numbers are small.
</p>
</answer>
<!-- <questionid="perf-spi"when="init"> Howtheperformanceofthepluggedincodewillbeenforced? <hint> Ifyouallowforeigncodetobepluggedintoyourownmodule,how doyouenforcethatitwillbehavecorrectlyandquicklyandwillnot negativelyinfluencetheperformanceofyourownmodule? </hint> </question>
-->
<answer id="perf-spi">
<p>
Some methods of the database runtimes may take a long time (especially
the start method). These methods are never called in the event thread and
a progress dialog is displayed.
</p>
</answer>
<!-- <questionid="resources-layer"when="final"> Doesyourmoduleprovideownlayer?Doesitcreateanyfilesor foldersinit?Whatitistryingtocommunicatebythatandwithwhich components? <hint> NetBeansallowsautomaticanddeclarativeinstallationofresources bymodulelayers.Moduleregisterfilesintoappropriateplaces andothercomponentsusethatinformationtoperformtheirtask (buildmenu,toolbar,windowlayout,listoftemplates,setof options,etc.). </hint> </question>
-->
<answer id="resources-layer">
<p>
Yes. The module contains a standard layer which describes menu items, actions and services. The
folders Databases/Connections, Databases/JDBCDrivers and Databases/Runtimes, where database connections,
JDBC drivers and database runtimes are registered, are created.
</p>
</answer>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.