Wiki source code of JDBC2XML Usage
Version 5.1 by christoph_lechleitner@iteg_at on 2012-11-27 02.27:45
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | = {{id name="JDBC2XMLUsage-JDBC2XMLUsage"/}}JDBC2XML Usage = | ||
| 2 | |||
| 3 | This section refers to the command-line tool. For information on the uses of the java library, please refer to our [[java documentation>>doc:JDBC2XML.Java Library Documentation.WebHome]]. | ||
| 4 | |||
| 5 | = {{id name="JDBC2XMLUsage-Commands"/}}Commands = | ||
| 6 | |||
| 7 | JDBC2XML provides several commands, triggering different operations. | ||
| 8 | |||
| 9 | The following command overview only shows the absolut minimal number of options. | ||
| 10 | |||
| 11 | Usually more options are needed, especially {{code language="none"}}--user{{/code}}, {{code language="none"}}--password{{/code}}, and (Linux only, see bottom) {{code language="none"}}--jdbc-drivers{{/code}}. | ||
| 12 | |||
| 13 | See far below for a full list of options, as well as examples for JDBC URLs. | ||
| 14 | |||
| 15 | ==== {{id name="JDBC2XMLUsage-DumpingaDBtoXML"/}}Dumping a DB to XML ==== | ||
| 16 | |||
| 17 | {{code language="none"}} | ||
| 18 | jdbc2xml --url <jdbc-url> --file <path-to-file> | ||
| 19 | {{/code}} | ||
| 20 | |||
| 21 | See below for details and example for JDBC URLs. | ||
| 22 | |||
| 23 | ==== {{id name="JDBC2XMLUsage-RestoringaDBfromXML"/}}Restoring a DB from XML ==== | ||
| 24 | |||
| 25 | {{code language="none"}} | ||
| 26 | xml2jdbc --file <path-to-file> --url <jdbc-url> | ||
| 27 | {{/code}} | ||
| 28 | |||
| 29 | ==== {{id name="JDBC2XMLUsage-CopyingfromoneDBtoanother"/}}Copying from one DB to another ==== | ||
| 30 | |||
| 31 | {{code language="none"}} | ||
| 32 | jdbc2jdbc --from-url <jdbc-url> --to-url <jdbc-url> | ||
| 33 | {{/code}} | ||
| 34 | |||
| 35 | ==== {{id name="JDBC2XMLUsage-ParseandcopyanXMLfile"/}}Parse and copy an XML file ==== | ||
| 36 | |||
| 37 | This can be useful for extracting a schema from a database (see options below) | ||
| 38 | |||
| 39 | {{code language="none"}} | ||
| 40 | xml2xml --from-file <path-to-file> --to-file <path-to-file> | ||
| 41 | {{/code}} | ||
| 42 | |||
| 43 | ==== {{id name="JDBC2XMLUsage-TestDBconnectionandserverstatus"/}}Test DB connection and server status ==== | ||
| 44 | |||
| 45 | {{code language="none"}} | ||
| 46 | jdbcping --url <jdbc-url> | ||
| 47 | {{/code}} | ||
| 48 | |||
| 49 | ==== {{id name="JDBC2XMLUsage-ExtractpartsofaDB"/}}Extract parts of a DB ==== | ||
| 50 | |||
| 51 | {{code language="none"}} | ||
| 52 | jdbcextr --url <jdbc-url> --file <path-to-file> | ||
| 53 | {{/code}} | ||
| 54 | |||
| 55 | == {{id name="JDBC2XMLUsage-JDBCURLs"/}}JDBC URLs == | ||
| 56 | |||
| 57 | JDBC URLs basically look like {{code language="none"}}jdbc:servertype://host[:port]/db?options{{/code}}., but some Databases and/or JDBC Drivers like other variants. | ||
| 58 | |||
| 59 | Typical examples are: | ||
| 60 | |||
| 61 | {{code language="none"}} | ||
| 62 | # MySQL | ||
| 63 | jdbc:mysql://localhost:3306/MYDATABASE?useCursorFetch=true | ||
| 64 | |||
| 65 | # MSSQL | ||
| 66 | jdbc:sqlserver://localhost:1433;databaseName=MYDATABASE; | ||
| 67 | {{/code}} | ||
| 68 | |||
| 69 | The use of cursor fetching in mysql is highly recommended in order to circumvent java heap space exceptions while dumping the content of large tables. | ||
| 70 | |||
| 71 | == {{id name="JDBC2XMLUsage-Fulllistofoptions"/}}Full list of options == | ||
| 72 | |||
| 73 | ==== {{id name="JDBC2XMLUsage-Databaseaccess"/}}Database access ==== | ||
| 74 | |||
| 75 | JDBC URL to access the DB. | ||
| 76 | |||
| 77 | {{code language="none"}} | ||
| 78 | --from-url "jdbcurl" | ||
| 79 | --to-url "jdbcurl" | ||
| 80 | --url "jdbcurl" | ||
| 81 | {{/code}} | ||
| 82 | |||
| 83 | User to access the DB (some drivers can parse that from the URL): | ||
| 84 | |||
| 85 | {{code language="none"}} | ||
| 86 | --from-user user | ||
| 87 | --to-user user | ||
| 88 | --user user | ||
| 89 | |||
| 90 | {{/code}} | ||
| 91 | |||
| 92 | Password to access the DB (some drivers can parse that from the URL): | ||
| 93 | |||
| 94 | {{code language="none"}} | ||
| 95 | --from-password password | ||
| 96 | --to-password password | ||
| 97 | --password password | ||
| 98 | {{/code}} | ||
| 99 | |||
| 100 | ==== {{id name="JDBC2XMLUsage-Fileaccess"/}}File access ==== | ||
| 101 | |||
| 102 | Win32 wrapper needs absolut paths. The given filenames may contain compressed input. The implementation instantiates an appropriate inflating/deflating stream if the filename ends with .gz or .bz2 | ||
| 103 | |||
| 104 | {{code language="none"}} | ||
| 105 | --from-file file | ||
| 106 | --to-file file | ||
| 107 | --file file | ||
| 108 | {{/code}} | ||
| 109 | |||
| 110 | ==== {{id name="JDBC2XMLUsage-Restrictprocessingtotables"/}}Restrict processing to tables ==== | ||
| 111 | |||
| 112 | Whitelist tables (comma seperated, without whitespace) | ||
| 113 | |||
| 114 | {{code language="none"}} | ||
| 115 | --tables table1,table2,... | ||
| 116 | {{/code}} | ||
| 117 | |||
| 118 | Blacklist tables | ||
| 119 | |||
| 120 | {{code language="none"}} | ||
| 121 | --exclude-tables table1,table2,... | ||
| 122 | {{/code}} | ||
| 123 | |||
| 124 | Do not include table data in dump (creates a full schema from a populated database): | ||
| 125 | |||
| 126 | {{code language="none"}} | ||
| 127 | --no-data | ||
| 128 | {{/code}} | ||
| 129 | |||
| 130 | Ignore constraints | ||
| 131 | |||
| 132 | {{code language="none"}} | ||
| 133 | --no-constraints | ||
| 134 | {{/code}} | ||
| 135 | |||
| 136 | Combined{{code language="none"}}--no-data{{/code}} and {{code language="none"}}--no-constraints{{/code}} | ||
| 137 | |||
| 138 | {{code language="none"}} | ||
| 139 | --schema-only | ||
| 140 | {{/code}} | ||
| 141 | |||
| 142 | ==== {{id name="JDBC2XMLUsage-Expertoptions"/}}Expert options ==== | ||
| 143 | |||
| 144 | Drop the affected tables before actually importing a dump. If {{code language="none"}}--tables{{/code}} or {{code language="none"}}--exclude-tables{{/code}} is given, only tables affected by the specified filter are dropped. | ||
| 145 | |||
| 146 | {{code language="none"}} | ||
| 147 | --drop-tables | ||
| 148 | {{/code}} | ||
| 149 | |||
| 150 | Overrides the default bzip2 output compression, if {{code language="none"}}--to-file{{/code}} ends with .bz2 | ||
| 151 | |||
| 152 | {{code language="none"}} | ||
| 153 | --compression <n> | ||
| 154 | {{/code}} | ||
| 155 | |||
| 156 | Force a timezone | ||
| 157 | |||
| 158 | {{code language="none"}} | ||
| 159 | --timezone timezoneid | ||
| 160 | {{/code}} | ||
| 161 | |||
| 162 | allows to select a JDBC driver, overriding autoselection | ||
| 163 | |||
| 164 | {{code language="none"}} | ||
| 165 | --from-driver drivername | ||
| 166 | --to-driver drivername | ||
| 167 | --driver drivername | ||
| 168 | {{/code}} | ||
| 169 | |||
| 170 | Linux only: add given drivers to the classpath | ||
| 171 | |||
| 172 | {{code language="none"}} | ||
| 173 | --jdbc-drivers jarfilename[;jarfilename...] | ||
| 174 | {{/code}} | ||
| 175 | |||
| 176 | ==== {{id name="JDBC2XMLUsage-Optionsforjdbcbehaviour"/}}Options for jdbc behaviour ==== | ||
| 177 | |||
| 178 | Change the batch size for inserts (def.: 1000) | ||
| 179 | |||
| 180 | {{code language="none"}} | ||
| 181 | --batch-size n | ||
| 182 | {{/code}} | ||
| 183 | |||
| 184 | Fetch the contents of the database using a read-only transaction | ||
| 185 | |||
| 186 | {{code language="none"}} | ||
| 187 | --transactional | ||
| 188 | {{/code}} | ||
| 189 | |||
| 190 | ==== {{id name="JDBC2XMLUsage-Optionsforxmlreading"/}}Options for xml reading ==== | ||
| 191 | |||
| 192 | Enable schema checking on the xml file | ||
| 193 | |||
| 194 | {{code language="none"}} | ||
| 195 | --check-xml-schema | ||
| 196 | {{/code}} | ||
| 197 | |||
| 198 | Create an extra index on each foreign key | ||
| 199 | |||
| 200 | {{code language="none"}} | ||
| 201 | --create-fk-indices | ||
| 202 | {{/code}} | ||
| 203 | |||
| 204 | ==== {{id name="JDBC2XMLUsage-Optionsforxmlcreation"/}}Options for xml creation ==== | ||
| 205 | |||
| 206 | Force or supress pretty printing of xml data | ||
| 207 | |||
| 208 | {{code language="none"}} | ||
| 209 | --pretty, --no-pretty | ||
| 210 | {{/code}} | ||
| 211 | |||
| 212 | Forces the transformation of SQL identifiers to lower case | ||
| 213 | |||
| 214 | {{code language="none"}} | ||
| 215 | --to-lower | ||
| 216 | {{/code}} | ||
| 217 | |||
| 218 | Force the transformation of SQL identifiers to upper case | ||
| 219 | |||
| 220 | {{code language="none"}} | ||
| 221 | --to-upper | ||
| 222 | {{/code}} | ||
| 223 | |||
| 224 | Write internal indices, which are generated by the RDBMS | ||
| 225 | |||
| 226 | {{code language="none"}} | ||
| 227 | --keep-internal-indices | ||
| 228 | {{/code}} | ||
| 229 | |||
| 230 | ==== {{id name="JDBC2XMLUsage-OutputVerbosity"/}}Output Verbosity ==== | ||
| 231 | |||
| 232 | The default log level prints {{code language="none"}}Fatal{{/code}}, {{code language="none"}}Error{{/code}} and {{code language="none"}}Warning{{/code}} logs | ||
| 233 | |||
| 234 | Suppresses any output except for the return code | ||
| 235 | |||
| 236 | {{code language="none"}} | ||
| 237 | --quiet | ||
| 238 | {{/code}} | ||
| 239 | |||
| 240 | Increase log-level to {{code language="none"}}Info{{/code}} | ||
| 241 | |||
| 242 | {{code language="none"}} | ||
| 243 | --verbose | ||
| 244 | {{/code}} | ||
| 245 | |||
| 246 | Log everything (command-line spam warning) | ||
| 247 | |||
| 248 | {{code language="none"}} | ||
| 249 | --debug | ||
| 250 | {{/code}} | ||
| 251 | |||
| 252 | Activate loggers in wrapper scripts (only useful if you know what you're doing) | ||
| 253 | |||
| 254 | {{code language="none"}} | ||
| 255 | --debug-startup | ||
| 256 | {{/code}} | ||
| 257 | |||
| 258 | === {{id name="JDBC2XMLUsage-Driverpackagesandpaths"/}}Driver packages and paths === | ||
| 259 | |||
| 260 | ====== {{id name="JDBC2XMLUsage-MySQL-Driver"/}}MySQL-Driver ====== | ||
| 261 | |||
| 262 | {{code language="none"}} | ||
| 263 | apt-get install libmysql-java | ||
| 264 | |||
| 265 | jdbc2xml ... --jdbc-drivers /usr/share/java/mysql-connector-java.jar | ||
| 266 | {{/code}} | ||
| 267 | |||
| 268 | ====== {{id name="JDBC2XMLUsage-MSSQL-Driver"/}}MSSQL-Driver ====== | ||
| 269 | |||
| 270 | {{code language="none"}} | ||
| 271 | apt-get install apache-karaf-mssql | ||
| 272 | |||
| 273 | jdbc2xml ... --jdbc-drivers /usr/share/apache-karaf/lib/sqljdbc4.jar | ||
| 274 | {{/code}} |