Setting up a JDBC Connection

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  SPS File and Databases > Connecting to a Database >

Setting up a JDBC Connection

JDBC (Java Database Connectivity) is a database access interface which is part of the Java software platform from Oracle. JDBC connections are generally more resource-intensive than ODBC connections but may provide features not available through ODBC.

 

Prerequisites

JRE (Java Runtime Environment) or Java Development Kit (JDK) must be installed. This may be either Oracle JDK or an open source build such as Oracle OpenJDK. StyleVision will determine the path to the Java Virtual Machine (JVM) from the following locations, in this order: a) The custom JVM path you may have set in application Options; b) The JVM path found in the Windows registry; c) The JAVA_HOME environment variable.
Make sure that the platform of StyleVision (32-bit, 64-bit) matches that of the JRE/JDK.
The JDBC drivers from the database vendor must be installed. If you are connecting to an Oracle database, note that some Oracle drivers are specific to certain JRE versions and may require additional components and configuration. The documentation of your Oracle product (for example, the "Oracle Database JDBC Developer's Guide and Reference") includes detailed instructions about the configuration procedure for each JDBC driver.
The CLASSPATH environment variable must include the path to the JDBC driver (one or several .jar files) on your Windows operating system. When you install some database clients, the installer may configure this variable automatically. The documentation of the JDBC driver will typically include step-by-step instructions on setting the CLASSPATH variable (see also Configuring the CLASSPATH).

 

Setting up a JDBC connection

1.Start the database connection wizard.
2.Click JDBC Connections.
3.Optionally, enter a semicolon-separated list of .jar file paths in the "Classpaths" text box. The .jar libraries entered here will be loaded into the environment in addition to those already defined in the CLASSPATH environment variable. When you finish editing the "Classpaths" text box, any JDBC drivers found in the source .jar libraries are automatically added to the "Driver" list (see the next step).

dbc_oracle_jdbc

4.Next to "Driver", select a JDBC driver from the list, or enter a Java class name. Note that this list contains any JDBC drivers configured through the CLASSPATH environment variable (see Configuring the CLASSPATH), as well as those found in the "Classpaths" text box.

The JDBC driver paths defined in the CLASSPATH variable, as well as any .jar file paths entered directly in the database connection dialog box are all supplied to the Java Virtual Machine (JVM). The JVM then decides which drivers to use in order to establish a connection. It is recommended to keep track of Java classes loaded into the JVM so as not to create potential JDBC driver conflicts and avoid unexpected results when connecting to the database.

5.Enter the username and password to the database in the corresponding boxes.
6.In the Database URL text box, enter the JDBC connection URL (string) in the format specific to your database type. The following table describes the syntax of JDBC connection URLs (strings) for common database types.

Database

JDBC Connection URL

Firebird

jdbc:firebirdsql://<host>[:<port>]/<database path or alias>

IBM DB2

jdbc:db2://hostName:port/databaseName

IBM DB2 for i

jdbc:as400://[host]

IBM Informix

jdbc:informix-sqli://hostName:port/databaseName:INFORMIXSERVER=myserver

MariaDB

jdbc:mariadb://hostName:port/databaseName

Microsoft SQL Server

jdbc:sqlserver://hostName:port;databaseName=name

MySQL

jdbc:mysql://hostName:port/databaseName

Oracle

jdbc:oracle:thin:@//hostName:port:service

Oracle XML DB

jdbc:oracle:oci:@//hostName:port:service

PostgreSQL

jdbc:postgresql://hostName:port/databaseName

Progress OpenEdge

jdbc:datadirect:openedge://host:port;databaseName=db_name

Sybase

jdbc:sybase:Tds:hostName:port/databaseName

Teradata

jdbc:teradata://databaseServerName

Note:Syntax variations to the formats listed above are also possible (for example, the database URL may exclude the port or may include the username and password to the database). Check the documentation of the database vendor for further details.

 

7.Click Connect.

© 2019 Altova GmbH