Teradata connectivity Issue through JDBC Driver in java


Teradata connectivity Issue through JDBC Driver in java


I am trying to connect my Teradata server through JDBC Driver in java using LDAP :

// Copyright (c) 2004-2008 by Teradata Corporation
// All Rights Reserved
// File: Sample2.java
// Purpose: This sample application will:
// - log on
// - log off

import java.sql.*;
import java.util.Properties;

public class Sample2
public static void main (String [] args)
throws ClassNotFoundException
// Teradata Type 4 JDBC Driver
String url = "jdbc:teradata://X.X.X.X/";

// Load the Teradata Driver
Class.forName ("com.teradata.jdbc.TeraDriver");

// Connect to the Teradata database specified in the URL
// and submit userid and password.
System.out.println("Connecting to " + url);

Properties props = new Properties();
props.setProperty("CHARSET", "UTF16");
props.setProperty("LOGMECH", "LDAP");
props.setProperty("LOGDATA", "USER@@PASSWORD");

Connection con = DriverManager.getConnection(url, props);

System.out.println("Established successful connection");

catch (SQLException ex)
// A SQLException was generated. Catch it and display
// the error information.
// Note that there could be multiple error objects chained
// together.
System.out.println("*** SQLException caught ***");

while (ex != null)
System.out.println(" Error code: " + ex.getErrorCode());
System.out.println(" SQL State: " + ex.getSQLState());
System.out.println(" Message: " + ex.getMessage());
ex = ex.getNextException();

throw new IllegalStateException ("Sample failed.") ;

I am using :

JDBC version : TeraJDBC__indep_indep.

Teradata version : 15.00

And I got this error:

*** SQLException caught ***
Error code: 1032
SQL State: HY000
Message: [Teradata JDBC Driver] [TeraJDBC] [Error 1032] [SQLState HY000] Single Sign-On NOT supported for Mechanism TD2.
java.sql.SQLException: [Teradata JDBC Driver] [TeraJDBC] [Error 1032] [SQLState HY000] Single Sign-On NOT supported for Mechanism TD2.
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:94)
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:69)
at com.teradata.jdbc.jdbc.GenericTeraEncrypt.initEncrypt(GenericTeraEncrypt.java:236)
at com.teradata.jdbc.jdbc.GenericTeraEncrypt.<init>(GenericTeraEncrypt.java:147)
at com.teradata.jdbc.jdbc.GenericLogonController.run(GenericLogonController.java:241)
at com.teradata.jdbc.jdbc_4.TDSession.<init>(TDSession.java:208)
at com.teradata.jdbc.jdk6.JDK6_SQL_Connection.<init>(JDK6_SQL_Connection.java:35)
at com.teradata.jdbc.jdk6.JDK6ConnectionFactory.constructSQLConnection(JDK6ConnectionFactory.java:25)
at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(ConnectionFactory.java:179)
at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(ConnectionFactory.java:169)
at com.teradata.jdbc.TeraDriver.doConnect(TeraDriver.java:234)
at com.teradata.jdbc.TeraDriver.connect(TeraDriver.java:160)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:187)
at Sample2.main(Sample2.java:40)

Exception in thread "main" java.lang.IllegalStateException: Sample failed.
at Sample2.main(Sample2.java:82)

Can you help me?



Teradata Employee

Re: Teradata connectivity Issue through JDBC Driver in java

When you use the DriverManager.getConnection(String url, Properties) method, the only properties that are supported in the Properties object are "username" and "password". Since you are trying to specify the username and password in the LOGDATA connection parameter, then the DriverManager.getConnection method with Properties argument will not be useful for you.

Instead, you should use the DriverManager.getConnection method without the Properties argument, and all the connection parameters must be specified in the URL, as follows:

String url = "jdbc:teradata://X.X.X.X/CHARSET=UTF16,LOGMECH=LDAP,LOGDATA=username@@password"; // replace with actual values

Connection con =  DriverManager.getConnection(url) ;