Quick Start: Progress Datadirect Connect: Connecting To A Database
Quick Start: Progress Datadirect Connect: Connecting To A Database
The following basic information allows you to connect with and test your Progress DataDirect Connect for JDBC drivers immediately after installation. For installation instructions, refer to the DataDirect Connect for JDBC Installation Guide.
Connecting to a Database
Once the DataDirect Connect for JDBC drivers are installed, you can connect from your application to your database in two ways: with the JDBC Driver Manager or with a JNDI data source. The following sections provide information you need to get started using the DataDirect Connect for JDBC drivers with the Driver Manager. For information on using data sources, refer to the DataDirect Connect for JDBC User's Guide. Click the following links for specific information about each driver: DB2 Driver Informix Driver MySQL Driver Oracle Driver SQL Server Driver Sybase Driver
DB2 Driver
Environment Setup
Set your system CLASSPATH to include the following entry: install_dir/lib/db2.jar
Driver Manager
To establish a database connection using the Driver Manager, an application must register the class name of the JDBC driver with the Driver Manager, and then invoke the DriverManager.getConnection() method while supplying a connection URL. IMPORTANT: If using Java SE 6 as a Java Virtual Machine (JVM), you do not need to register the driver and can skip this step. Java SE 6 automatically registers the driver with the JDBC Driver Manager. The classname and connection URL syntax for the DB2 driver are: Driver Classname: Connection URL: com.ddtek.jdbc.db2.DB2Driver DB2 for Linux/UNIX/Windows: jdbc:datadirect:db2://servername:port;DatabaseName=db_name [;property=value[;...]] DB2 for z/OS and iSeries: jdbc:datadirect:db2://servername:port;LocationName=location_name [;property=value[;...]] For example, to connect to a DB2 for Linux/UNIX/Windows database named ACCTNG on the server named corpserver1 on port 50000, the following URL would be used: jdbc:datadirect:db2://corpserver1:50000;DatabaseName=ACCTNG
Similarly, to connect to a DB2 for z/OS or iSeries database with a location name of ACCTNG on the server named corpserver1 on port 50000, the following URL would be used: jdbc:datadirect:db2://corpserver1:50000;LocationName=ACCTNG Refer to the DataDirect Connect for JDBC Users Guide for a complete description of the connection URL syntax and descriptions of the connection properties that can be specified.
Examples
DB2 for Linux/UNIX/Windows: // Register the driver with the driver manager. // If using Java SE 6, you can omit this step. // Java SE 6 automatically registers the driver. Class.forName("com.ddtek.jdbc.db2.DB2Driver"); // Establish the Connection String url = "jdbc:datadirect:db2://corpserver1:50000;DatabaseName=ACCTNG"; Connection con = DriverManager.getConnection(url, "test04", "test04"); // Verify the Connection DatabaseMetaData metaData = con.getMetaData(); System.out.println("Database Name: " + metaData.getDatabaseProductName()); System.out.println("Database Version: " + metaData.getDatabaseProductVersion()); DB2 UDB for z/OS and iSeries: // Register the driver with the driver manager // If using Java SE 6, you can omit this step. // Java SE 6 automatically registers the driver. Class.forName("com.ddtek.jdbc.db2.DB2Driver"); // Establish the Connection String url = "jdbc:datadirect:db2://corpserver1:50000;LocationName=ACCTNG"; Connection con = DriverManager.getConnection(url, "test04", "test04"); // Verify the Connection DatabaseMetaData metaData = con.getMetaData(); System.out.println("Database Name: " + metaData.getDatabaseProductName()); System.out.println("Database Version: " + metaData.getDatabaseProductVersion());
Informix Driver
Environment Setup
Set your system CLASSPATH to include the following entry: install_dir/lib/informix.jar
Driver Manager
To establish a database connection using the Driver Manager, an application must register the class name of the JDBC driver with the Driver Manager, and then invoke the DriverManager.getConnection() method while supplying a connection URL. IMPORTANT: If using Java SE 6 as a JVM, you do not need to register the driver and can skip this step. Java SE 6 automatically registers the driver with the JDBC Driver Manager. The classname and connection URL syntax for the Informix driver are: Driver Classname: Connection URL: com.ddtek.jdbc.informix.InformixDriver jdbc:datadirect:informix://servername:port;InformixServer=server_name [;property=value[;...]]]
For example, to connect to a database named ACCTNG in the Informix server instance named corpSrvr on the server named corpserver1 on port 2003, the following URL would be used: jdbc:datadirect:informix://corpserver1:2003;InformixServer=corpSrvr; DatabaseName=ACCTNG Refer to the DataDirect Connect for JDBC Users Guide for a complete description of the connection URL syntax and a description of the connection properties that can be specified.
Example
// Register the driver with the driver manager. // If using Java SE 6, you can omit this step. // Java SE 6 automatically registers the driver. Class.forName("com.ddtek.jdbc.informix.InformixDriver"); // Establish the Connection String url = "jdbc:datadirect:informix://corpserver1:2003; InformixServer=corpSrvr;DatabaseName=ACCTNG"; Connection con = DriverManager.getConnection(url, "test04", "test04"); // Verify the Connection DatabaseMetaData metaData = con.getMetaData(); System.out.println("Database Name: " + metaData.getDatabaseProductName()); System.out.println("Database Version: " + metaData.getDatabaseProductVersion());
MySQL Driver
Environment Setup
Set your system CLASSPATH to include the following entry: install_dir/lib/mysql.jar
Driver Manager
To establish a database connection using the Driver Manager, an application must register the class name of the JDBC driver with the Driver Manager, and then invoke the DriverManager.getConnection() method while supplying a connection URL. IMPORTANT: If using Java SE 6 as a JVM, you do not need to register the driver and can skip this step. Java SE 6 automatically registers the driver with the JDBC Driver Manager. The classname and connection URL syntax for the MySQL driver are: Driver Classname: Connection URL: com.ddtek.jdbc.mysql.MySQLDriver jdbc:datadirect:mysql://hostname:[port][;property=value[;...]]
For example, to connect to a database named ACCTNG on the server named corpserver1 on port 3306, the following URL would be used: jdbc:datadirect:mysql://corpserver1:3306;DatabaseName=ACCTNG Refer to the DataDirect Connect for JDBC User's Guide for a complete description of the connection URL syntax and descriptions of the connection properties that can be specified.
Example
// Register the driver with the driver manager. // If using Java SE 6, you can omit this step. // Java SE 6 automatically registers the driver. Class.forName("com.ddtek.jdbc.mysql.MySQLDriver"); // Establish the Connection String url = "jdbc:datadirect:mysql://corpserver1:3306;DatabaseName=ACCTNG"; Connection con = DriverManager.getConnection(url, "test04", "test04"); // Verify the Connection DatabaseMetaData metaData = con.getMetaData(); System.out.println("Database Name: " + metaData.getDatabaseProductName()); System.out.println("Database Version: " + metaData.getDatabaseProductVersion());
Oracle Driver
Environment Setup
Set your system CLASSPATH to include the following entry: install_dir/lib/oracle.jar
Driver Manager
To establish a database connection using the Driver Manager, an application must register the class name of the JDBC driver with the Driver Manager, and then invoke the DriverManager.getConnection() method while supplying a connection URL. IMPORTANT: If using Java SE 6 as a JVM, you do not need to register the driver and can skip this step. Java SE 6 automatically registers the driver with the JDBC Driver Manager. The classname and connection URL syntax for the Oracle driver are: Driver Classname: Connection URL: com.ddtek.jdbc.oracle.OracleDriver jdbc:datadirect:oracle://servername:port;[;property=value [;...]]
For example, to connect to Oracle instance named test on the server named corpserver1 on port 1521, the following URL would be used: jdbc:datadirect:oracle://corpserver1:1521;ServiceName=test Refer to the DataDirect Connect for JDBC Users Guide for a complete description of the connection URL syntax and descriptions of the connection properties that can be specified.
Example
// Register the driver with the driver manager. // If using Java SE 6, you can omit this step. // Java SE 6 automatically registers the driver. Class.forName("com.ddtek.jdbc.oracle.OracleDriver"); // Establish the Connection String url = "jdbc:datadirect:oracle://corpserver1:1521;ServiceName=test"; Connection con = DriverManager.getConnection(url, "test04", "test04"); // Verify the Connection DatabaseMetaData metaData = con.getMetaData(); System.out.println("Database Name: " + metaData.getDatabaseProductName()); System.out.println("Database Version: " + metaData.getDatabaseProductVersion());
Driver Manager
To establish a database connection using the Driver Manager, an application must register the class name of the JDBC driver with the Driver Manager, and then invoke the DriverManager.getConnection() method while supplying a connection URL. IMPORTANT: If using Java SE 6 as a JVM, you do not need to register the driver and can skip this step. Java SE 6 automatically registers the driver with the JDBC Driver Manager. The classname and connection URL syntax for the SQL Server driver are: Driver Classname: Connection URL: com.ddtek.jdbc.sqlserver.SQLServerDriver jdbc:datadirect:sqlserver://servername:port[;property=value [;...]]
For example, to connect to a database named ACCTNG on the server named corpserver1 on port 1433, the following URL would be used: jdbc:datadirect:sqlserver://corpserver1:1433;DatabaseName=ACCTNG Refer to the DataDirect Connect for JDBC Users Guide for a complete description of the connection URL syntax and descriptions of the connection properties that can be specified.
Example
// Register the driver with the driver manager. // If using Java SE 6, you can omit this step. // Java SE 6 automatically registers the driver. Class.forName("com.ddtek.jdbc.sqlserver.SQLServerDriver"); // Establish the Connection String url = "jdbc:datadirect:sqlserver://corpserver1:1433; DatabaseName=ACCTNG"; Connection con = DriverManager.getConnection(url, "test04", "test04"); // Verify the Connection DatabaseMetaData metaData = con.getMetaData(); System.out.println("Database Name: " + metaData.getDatabaseProductName()); System.out.println("Database Version: " + metaData.getDatabaseProductVersion());
Sybase Driver
Environment Setup
Set your system CLASSPATH to include the following entry: install_dir/lib/sybase.jar
Driver Manager
To establish a database connection using the Driver Manager, an application must register the class name of the JDBC driver with the Driver Manager, and then invoke the DriverManager.getConnection() method while supplying a connection URL. IMPORTANT: If using Java SE 6 as a JVM, you do not need to register the driver and can skip this step. Java SE 6 automatically registers the driver with the JDBC Driver Manager. The classname and connection URL syntax for the Sybase driver are: Driver Classname: Connection URL: com.ddtek.jdbc.sybase.SybaseDriver jdbc:datadirect:sybase://servername:port[;property=value [;...]]
For example, to connect to a database named ACCTNG on the server named corpserver1 on port 4100, the following URL would be used: jdbc:datadirect:sybase://corpserver1:4100;DatabaseName=ACCTNG Refer to the DataDirect Connect for JDBC Users Guide for a complete description of the connection URL syntax and descriptions of the connection properties that can be specified.
Example
// Register the driver with the driver manager. // If using Java SE 6, you can omit this step. // Java SE 6 automatically registers the driver. Class.forName("com.ddtek.jdbc.sybase.SybaseDriver"); // Establish the Connection String url = "jdbc:datadirect:sybase://corpserver1:4100;DatabaseName=ACCTNG"; Connection con = DriverManager.getConnection(url, "test04", "test04"); // Verify the Connection DatabaseMetaData metaData = con.getMetaData(); System.out.println("Database Name: " + metaData.getDatabaseProductName()); System.out.println("Database Version: " + metaData.getDatabaseProductVersion());
7/10