##### jdbc2http

- Overview
- Connection
- Limitations
- Download

##### Supported Databases

- Overview
- MySQL

##### Server Side Drivers

- Scripts
  - Login - dologin.php
  - Logout - dologout.php
  - Metadata - dodbmeta.php
  - Set Parameters - doparam.php
  - SQL - dosql.php
  - Prepared Statements

##### Project Documentation

- Project Information
- Project Reports

## dosql.php

This script executes a set of SQL statements.

The entire set of statements is executed within a database transaction, which is rolled back if an error occurs and the database can handle transactions.

The current session must contain the connection parameters for database access.

dosql.php processes the following HTTP parameters:

PHPSESSID
  (required) the session ID returned from dologin.php
sql:$i
  (required) where $i = 0, 1, ... the SQL statements to be executed
return-keys
  (optional) true if server generated keys of inserted rows shall be returned. false by default.
permit-results
  (optional) true if SQL statements may return result sets. true by default.
format
  (optional) the format used to transmit the SQL result set. Can be either xml (default) or csv.
delimiter
  (optional) the column delimiter used for CSV downloads. Default is a semicolon (;).
quote
  (optional) the quote character used to enclose complex column values in CSV format. Defaults to a double quote (").

The response structure returned by dosql.php is an XML document as outlined below:

    <result>
            <update>
                    <rows>number of rows affected by statement sql:0</rows>
                    <keys>
                            ... result-set for keys generated by statement sql:0 ...
                    </keys>
            </update>
            <update>
                    <rows>number of rows affected by statement sql:1</rows>
                    <keys>
                            ... result-set for keys generated by statement sql:1 ...
                    </keys>
            </update>
            ...
            <result-set>
                    <columns>
                            <column>
                                    <name>name_of_column_1</name>
                                    <type>sql_type_of_column_1</type>
                            </column>
                            <column>
                                    <name>name_of_column_2</name>
                                    <type>sql_type_of_column_2</type>
                            </column>
                            ...
                    </columns>

                    ... data ...

            </result-set>
    </result>

If the reqired format was xml, the data node looks like this:

            <data>
            <row>
                            <col>data for row 1 column 1</col>
                            <col>data for row 1 column 2</col>
                            ...
                    </row>
                    <row>
                            <col>data for row 2 column 1</col>
                            <col>data for row 2 column 2</col>
                            ...
                    </row>
                    ...
            </data>

If csv format was requested, the following data node is returned:

            <csvdata><![CDATA[row 1 in CSV format
    row 2 in CSV format
    ...
    ]]></csvdata>

In case of errors or warnings, the following XML nodes may be inserted anywhere in the response:

    <error>
            <reason>error message</reason>
            <sqlstate>SQL state</sqlstate>
            <vendor-code>vendor code</vendor-code>
    </error>

    <warning>
            <reason>error message</reason>
            <sqlstate>SQL state</sqlstate>
            <vendor-code>vendor code</vendor-code>
    </warning>