Document Revision: 1
Release Information | |
---|---|
Project | JDBWC |
Version | 1.0.0-3beta |
License | GNU GPLv3 http://www.gnu.org/licenses/ |
Web | http://jdbwc.sourceforge.net/ |
Support | https://sourceforge.net/projects/jdbwc/support |
This document requires you have some knowledge of web-servers and the Java programming language (and ideally JDBC). Its beyond the scope of this document to explain these subjects in great detail.
Throughout this document there are some descriptive terms that may be unclear. Their meanings are clarified below.
Client Side:
the Java JDBC part of the JDBWC Driver.
Also referred to as JDBC (Java DataBase Connector).
Server-Side:
the PHP side (with a web-server and one or more database-server/s).
Also referred to as WC (Web Connector).
Upstream:
data going from the Client-side to the Server-side.
Downstream:
data going from the Server-side to the Client-side.
JDBWC is an acronym for Java-Data-Base-Web-Connector. In essence, JDBWC is a Java JDBC Driver with its own server written in PHP. Ideally suited to Java Desktop applications that require JDBC access across wide area networks like the internet but do not wish to expose the remote database-server through the remote hosts firewall. EG: the database server does not need to be exposed to the internet at all.
Client-side:
Java JRE >= 1.6.0_19 (you can also compile from source to suit your target JRE)
Server-side:
Apache-Web-server >= 1.3.41
PHP >= 5.1.x with MySQL >= 5.x.x and/or PostgreSQL >= 7.4.x
If your using MySQL you should enable the
PHP mysqli extension for full metadata functionality.
The existence of the mysqli extension is determined on the server-side.
Supplied dependencies (licensed under the Apache-2 license)
Commons-HttpClient 3.1
jdbwc-lib
" folder containing "jdbwc.jar
" and dependencies
to a location relative to your Java application files. Class-Path: jdbwc-lib/jdbwc.jar or Class-Path: jdbwc.jar
depending on where you put the jar files in relation to your java app. IDE's usually require all of the jars in the build path.
For apps, the required jdbwc dependencies will be added to your classpath by jdbwc.jar
Once the Server-side portion is installed and configs are set you can forget about it.
It only interacts with the JDBC portion and doesn't need to be maintained.
It does maintain an event.log file that you may want to
look at occasionally to see what's been happening on your server.
The event.log can be invaluable for debugging, however any exceptions or errors encountered on
the server will be thrown back to the JDBC driver as an SQL exception (or extension of).
Most PHP warnings will only be logged, not relayed as they usually aren't critical and don't warrant halting the driver.
SQL errors will contain the database servers original message with the offending SQL
query below that. The usual java exception trail will follow.
It will also be logged in the servers event log as an SQL-ERROR.
In the distribution package you will find a zip file called server-side-bundle.zip
.
It contains some optional testing files which are explained in the README inside the zip.
NOTE: The folder: "jdbwc/includes/config/local
" is for testing servers and is not needed
for servers with a registered domain name. Its supplied for convenience when developing.
The "jdbwc/includes/config/local
" folder should _NOT_ be uploaded to production machines.
http://yourserver.ext/jdbwc
, http://yourserver.ext/subfolder/anotherfolder/jdbwc
jdbwc/includes/config/configure.php
" jdbwc/includes/config/databases.php
" jdbwc/includes/wc_logs
" full write permissions.jdbwc/includes/sessions
" full write permissions andjdbwc/includes/sessions/phpsess.db
" (sqlite database) write permissions if you chose sqlite as the session handler (in the configure.php
file).That's about it.
See the bundled jdbwctest.zip
file in the distribution folder for details on how to setup your java class/s
to use the jdbwc.jar (JDBC driver). Look in the connect()
method for some examples.
Also have a look at the test class in the file jdbwctest.zip
(included in the distribution).
There are a number of optional connection parameters you can use to fine tune the connection.
The list of optional params may change between different releases depending on additional functionality supported by the driver.
See the section on Connection Parameters in detail for more info.
JDBWC is a JDBC Driver, so the standard JDBC syntax applies for general use.
To start a JDBC connection using JDBWC
you need to register the driver with the JRE's DriverManager
and then start a new JDBC connection using a JDBWC specific URL.
The required url syntax and parameters are demonstrated in the example.
Parameters (everything after the ?) can be in any order.
Registering the driver requires a ClassNotFoundException
handler,
starting a new Connection requires an SQLException
handler.
See the example below.
NOTE: SSL is highly recommended over sending sql in plaintext.
v1.0.0.3 will only work with validated certs.
jdbc:jdbwc://
Requests a default connection from JDBWC. The default is MySql.
jdbc:jdbwc:mysql//
Requests a MySql connection from JDBWC.
jdbc:jdbwc:postgresql//
Requests a PostgreSql connection from JDBWC.
url
The website URL containing the JDBWC server-side PHP bundle.
The url must start with a protocol (http or https) and have a trialing /
EG: https://mydomain.ext/myfolder/myotherfolder/
The JDBWC driver will append jdbwc/index.php
to the end of this URL before requesting a connection from the server.
port
The port number the web-server responds to. In this release, only standard ports can be used.
80 is standard for http requests
443 is standard for https
user
The user name you specified in the server-side configure.php
file.
password
The password you specified in the server-side configure.php
file.
databaseName
One of the database names you specified in the server-side databases.php
file.
databaseUser
One of the database user-names you specified in the server-side databases.php
file.
databasePassword
One of the database passwords you specified in the server-side databases.php
file.
debug
Turns debugging on or off. Its off by default. The other debugXX
options will only take effect if this option is set to true
.
OPTIONS: true, false (or not used. defaults to false)
debugLogger
The type of logger to use for logging. Although there are 3 options, only SimpleLog will work with this release. To find out more about the logger see: http://hc.apache.org/httpclient-3.x/logging.html
OPTIONS: SimpleLog, Jdk14Logger, Log4JLogger
debugLevel
Debugging level:
0 JDBWC informative/debugging,
1 JDBWC debugging,
2 JDBWC debugging and Enable header wire + context logging - Best for Debugging,
3 JDBWC debugging and Enable full wire + context logging.
OPTIONS: [0-3]
useDummyAgent
This is rarely required. Its for situations where the host server blocks the default HttpClient User-Agent
. The server would need to have been configured to deliberately block the HttpClient user agent.
OPTIONS: true, false (or not used. defaults to false)
ParameterMetaData
functionality for PreparedStatement
.Driver.getPropertyInfo()
ResultsetMetaData
. ParameterMetaData
testing.connect()
method.NOTE: Its strongly advised to use an SSL connection when communicating across a network or the internet as you will be sending raw sql. To correctly install SSL your web-server must have a dedicated IP.
If you notice any, please report them in the projects bug-tracking area at: http://sourceforge.net/tracker/?group_id=233279&atid=1089227
Please be specific with bug reports so they can be properly attended to. Vague reports will not be attended to unless the error is quite obvious.
Include some code or a description of the conditions you encountered the bug in so it can be reproduced. The more detail, the higher the chance of it being fixed quickly.
NOTE: NotImplemented
exceptions are not bugs. They are features that have not been fully implemented yet and will vary for each release. This technique of dealing with unfinished areas is part of the JDBC specification for drivers [http://java.sun.com/products/jdbc/driverdevs.html].
If you would like to see a particular feature implemented, please make a feature request at: http://sourceforge.net/tracker/?group_id=233279&atid=1089230