JDBC Checker
From MediaWiki
Line 44: | Line 44: | ||
your JDBC driver is compatible with DB, otherwise it is not and you should change it. | your JDBC driver is compatible with DB, otherwise it is not and you should change it. | ||
+ | |||
+ | This is the example of <code>build.xml</code> file in the case of Oracle database | ||
+ | |||
+ | <!-- JDBC Checker --> | ||
+ | <!-- Dusan Vudragovic <dusan@ipb.ac.rs> --> | ||
+ | <!-- 2008-01-31 --> | ||
+ | <project name="JDBC Checker" | ||
+ | default="check" | ||
+ | basedir="."> | ||
+ | <description> | ||
+ | ANT build file which allows to check compatibility | ||
+ | between JDBC driver and database. | ||
+ | </description> | ||
+ | <target name="check"> | ||
+ | <sql driver="oracle.jdbc.driver.OracleDriver" | ||
+ | onerror="stop" | ||
+ | url="jdbc:oracle:thin:@(DESCRIPTION = | ||
+ | (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr8-v.cern.ch)(PORT = 10121)) | ||
+ | (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr7-v.cern.ch)(PORT = 10121)) | ||
+ | (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr3-v.cern.ch)(PORT = 10121)) | ||
+ | (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr4-v.cern.ch)(PORT = 10121)) | ||
+ | (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr5-v.cern.ch)(PORT = 10121)) | ||
+ | (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr6-v.cern.ch)(PORT = 10121)) | ||
+ | (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr1-v.cern.ch)(PORT = 10121)) | ||
+ | (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr2-v.cern.ch)(PORT = 10121)) | ||
+ | (ENABLE=BROKEN) | ||
+ | (LOAD_BALANCE = yes) | ||
+ | (CONNECT_DATA = | ||
+ | (SERVER = DEDICATED) | ||
+ | (SERVICE_NAME = lcg_same.cern.ch) | ||
+ | (FAILOVER_MODE = (TYPE = SELECT)(METHOD = BASIC)(RETRIES = 200)(DELAY = 15))))" | ||
+ | userid="lcg_same_r" | ||
+ | password="xxxxxx"> | ||
+ | <classpath> | ||
+ | <pathelement path="usr/lib/oracle/xe/app/oracle/product/10.2.0/client/lib/ojdbc14.jar"/> | ||
+ | </classpath> | ||
+ | select * from tab; | ||
+ | </sql> | ||
+ | </target> | ||
+ | </project> |
Revision as of 09:33, 11 February 2008
This is a simple way of checking compatibility between JDBC driver and database with Ant. Ant has integrated support for access to SQL databases which is used by following build file
[dusan@woodoo JDBCChecker]$ cat build.xml <project name="JDBC Checker" default="check" basedir="."> <description> ANT build file which allows checking the compatibility between JDBC driver and database. </description> <target name="check"> <sql driver="<insert JDBC URL>" onerror="stop" url="<insert connection URL>" userid="<insert user name>" password="<insert password>"> <classpath> <pathelement path="<insert path to JDBC driver here>"/> </classpath> </sql> </target> </project>
Possible values of the JDBC URL are: jdbc.driver.OracleDriver
, oracle.jdbc.driver.OracleDriver
,... in the case of Oracle database or com.mysql.jdbc.Driver
,... in the case of MySQL database.
Possible values of the connection URL are: jdbc:oracle:thin:@machine_name:port_number:instance_name
for the Orace Type 4 JDBC Driver or jdbc:mysql://host_name:port/dbname
for the MySQL Connector/J JDBC Driver.
If ant check
command retrieves something like
[dusan@woodoo jdbc]$ ant check Buildfile: build.xml check: [sql] Executing commands [sql] 1 of 1 SQL statements executed successfully BUILD SUCCESSFUL Total time: 1 second
your JDBC driver is compatible with DB, otherwise it is not and you should change it.
This is the example of build.xml
file in the case of Oracle database
<project name="JDBC Checker" default="check" basedir="."> <description> ANT build file which allows to check compatibility between JDBC driver and database. </description> <target name="check"> <sql driver="oracle.jdbc.driver.OracleDriver" onerror="stop" url="jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr8-v.cern.ch)(PORT = 10121)) (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr7-v.cern.ch)(PORT = 10121)) (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr3-v.cern.ch)(PORT = 10121)) (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr4-v.cern.ch)(PORT = 10121)) (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr5-v.cern.ch)(PORT = 10121)) (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr6-v.cern.ch)(PORT = 10121)) (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr1-v.cern.ch)(PORT = 10121)) (ADDRESS = (PROTOCOL = TCP)(HOST = lcgr2-v.cern.ch)(PORT = 10121)) (ENABLE=BROKEN) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = lcg_same.cern.ch) (FAILOVER_MODE = (TYPE = SELECT)(METHOD = BASIC)(RETRIES = 200)(DELAY = 15))))" userid="lcg_same_r" password="xxxxxx"> <classpath> <pathelement path="usr/lib/oracle/xe/app/oracle/product/10.2.0/client/lib/ojdbc14.jar"/> </classpath> select * from tab; </sql> </target> </project>