No suitable driver found for jdbc issue even after downloading the teradata v 14 jdbc drivers

Connectivity

No suitable driver found for jdbc issue even after downloading the teradata v 14 jdbc drivers

Hi,

I am trying to connect to Teradata (13.10.06.01) from a Java application (Rational Software Architect). I have tried with both the version 14 and 13 JDBC drivers from the below site but still no luck.

http://downloads.teradata.com/download/connectivity/jdbc-driver

Can one of you please help me? Below are the code and error messages.

package com.target.gdas.dds;

 

import java.sql.*;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import java.util.ArrayList;

 

public class EDWDAO {

public static void main(String[] args) {

// EDWDAO edwDAO = new EDWDAO();

try {

EDWDAO.getConnection();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (InstantiationException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IllegalAccessException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (ClassNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

private static Connection conn;

 

public static Connection getConnection() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException

{

Class.forName("com.teradata.jdbc.TeraDriver");

 

conn = DriverManager.getConnection("jdbc:teradata://databasename", "username", "password");

 

return conn;

}

public static ArrayList<String[]> queryADWDbDataBlock(String queryString) throws SQLException {

System.out.println("queryString::::"+queryString);

 

Connection conn = null;

ResultSet rs = null;

try {

conn = getConnection();

rs = doQuery(conn, queryString);

 

}

catch (SQLException e) {

e.printStackTrace();

}

catch (InstantiationException e) {

e.printStackTrace();

} catch (IllegalAccessException e) {

e.printStackTrace();

} catch (ClassNotFoundException e) {

e.printStackTrace();

}

//Convert the completed query to a format that can be used by the Excel Driver

ArrayList<String[]> dataBlock = DataHelper.rs2ArrayList(rs);

//This closes the result set and statement

conn.commit();

conn.close();

//Reformat MS Access Dates

dataBlock = MasterCalendarDAO.reformatAccessData(dataBlock);

 

return dataBlock;

}

 

public static ResultSet doQuery(Connection conn, String query) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException

{

 

Statement statement = conn.createStatement();

if (statement == null) {

System.out.println("ERROR: EDWDAO.doQuery()-Could not create the Query Statement");

return null;

}

 

ResultSet rs = statement.executeQuery(query);

System.out.println("statement.executeQuery(query):::"+statement.executeQuery(query));

 

if (rs == null) {

System.out.println("ERROR: EDWDAO.doQuery() Returned RecordSet is null");

}

conn.commit();

return rs;

 

}

}

Error Message:

java.sql.SQLException: No suitable driver found for jdbc:teradata:tdproda

at java.sql.DriverManager.getConnection(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at com.target.gdas.dds.EDWDAO.getConnection(EDWDAO.java:35)

at com.target.gdas.dds.EDWDAO.main(EDWDAO.java:14)

6 REPLIES
Teradata Employee

Re: No suitable driver found for jdbc issue even after downloading the teradata v 14 jdbc drivers

You must have both terajdbc4.jar and tdgssconfig.jar listed on your classpath.

The most likely cause for the exception you received is that you are missing terajdbc4.jar on your classpath.

Re: No suitable driver found for jdbc issue even after downloading the teradata v 14 jdbc drivers

Thank you Tom for replying. Yes, I have included both terajdbc4.jar and tdgssconfig.jar in my classpath.

I tried couple of syntaxes for connection url in DriverManager.getConnection with each syntax I am getting a different error. So, I am thinking this is most likely an issue with the syntax of connection url.

Can you please help me with the correct syntax of connection url?

Teradata Employee

Re: No suitable driver found for jdbc issue even after downloading the teradata v 14 jdbc drivers

The Teradata JDBC Driver URL Connection syntax is documented in the Teradata JDBC Driver Reference here on Developer Exchange. Here is a direct link to the relevant section: http://developer.teradata.com/doc/connectivity/jdbc/reference/current/jdbcug_chapter_2.html#BABJIHBJ

Also, you can find actual example connection URLs in our sample programs, which are also available here on Developer Exchange:

http://developer.teradata.com/doc/connectivity/jdbc/reference/current/samplePrograms.html

Re: No suitable driver found for jdbc issue even after downloading the teradata v 14 jdbc drivers

Thanks again Tom. I have used the below url as per your guidance.

"jdbc:teradata://tdproda/TMODE=ANSI,CHARSET=UTF8"

As a result I am getting the below error.

com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata Database] [TeraJDBC 14.10.00.17] [Error 8017] [SQLState 28000] The UserId, Password or Account is invalid.

After doing some research I did found that the below solution in the forums.

Cause


LOGMECH=LDAP is specified, and the username/password credentials are redundantly provided in the both LOGDATA and as separate connection parameters.


Solution


Identify LDAP users via LOGDATA, or via separate username/password parameters, but not both simultaneously.


I am not sure what exactly needs to be done by this solution. Can you please help me? Just wanted to clarify that I am able to login with the same user id and password via Teradata Sql Assistant.

I did try changing the url as shown below.

"jdbc:teradata://tdproda/TMODE=ANSI,CHARSET=UTF8,LOGMECH={LDAP}"

Then, I am getting the below error. Please help me navigate through this.

com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata JDBC Driver] [TeraJDBC 14.10.00.17] [Error 1035] [SQLState HY000] Authentication Mechanism {LDAP} is not supported on this machine.

Enthusiast

Re: No suitable driver found for jdbc issue even after downloading the teradata v 14 jdbc drivers

LOGMECH=LDAP

Here is a code I developed. 

public class TeraConTT {
private String tdp;
private String username;
private String password;
private String conMech = "LDAP";
private String sql;
private boolean debug;

private String errMsg;
private Connection con;
private PreparedStatement st;

public int connect() throws ExportException {
if (!validate()) {

throw new ExportException(errMsg);
}

String url = "jdbc:teradata://" + tdp
+ "/CHARSET=ASCII"
+ ",LOGMECH=" + conMech;
if(debug){
url = url+",LOG=TIMING";
}
try {
Class.forName("com.teradata.jdbc.TeraDriver");
con = DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
throw new ExportException(e);
} catch (SQLException e) {
// TODO Auto-generated catch block
throw new ExportException(e);
}

return 0;
}

private boolean validate() {
if ("".equals(tdp.trim())) {
errMsg = "Empty tdp address";
return false;
}
if ("".equals(username.trim())) {
errMsg = "Empty username";
return false;
}
if ("".equals(password.trim())) {
errMsg = "Invalidate password";
return false;
}

if (sql.contains(";")) {
errMsg = "No semicolon allowed in sql";
return false;
}

return true;
}

public ResultSet executeQry() throws ExportException {
ResultSet rs = null;
st = null;
try {
st = con.prepareStatement(sql);
rs = st.executeQuery();

} catch (SQLException e) {
// TODO Auto-generated catch block
//e.addSuppressed(e.getNextException());
throw new ExportException(e);
}

return rs;
}

public int executeDDL(String sql) throws ExportException {
Statement st = null;
int rc = 0;
try {
st = con.createStatement();
rc = st.executeUpdate(sql);
} catch (SQLException e) {
throw new ExportException(e);
}
return rc;
}

public String executeNative(String cmd) throws ExportException {
String rc = null;
try {
rc = con.nativeSQL(cmd);
} catch (SQLException e) {
throw new ExportException(e);
}
return rc;
}

public void close() throws ExportException {
try {
if (st != null)
st.close();
if (con != null) {
SQLWarning w = con.getWarnings();
// Note that there could be multiple SQLWarning objects
// chained together!
while (w != null) {
System.out.println("*** SQLWarning caught ***");

System.out.println(
"SQL State = " + w.getSQLState()
+ ", Error Code = " + w.getErrorCode()
+ "\n" );
w.printStackTrace();
}
con.close();
}
} catch (SQLException e) {

throw new ExportException(e);
}
}

public String getTdp() {
return tdp;
}

public void setTdp(String tdp) {
this.tdp = tdp;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public int getSessCnt() {
return sessCnt;
}

public void setSessCnt(int sessCnt) {
this.sessCnt = sessCnt;
}

public String getSql() {
return sql;
}

public void setSql(String sql) {
this.sql = sql;
}

public String getConMech() {
return this.conMech;
}

public void setConMech(String conMech) {
this.conMech = conMech;
}

public boolean isDebug() {
return debug;
}

public void setDebug(boolean debug) {
this.debug = debug;
}

}
Teradata Employee

Re: No suitable driver found for jdbc issue even after downloading the teradata v 14 jdbc drivers

@sirisha.sindiri

First question: Does your Teradata environment actually use LDAP authentication? You should only specify LOGMECH=LDAP if your Teradata environment is configured to support LDAP authentication.

Secondly, you have a syntax error in your example JDBC Connection URL. You should NOT specify curly braces around the authentication mechanism name. In other words, do NOT specify LOGMECH={LDAP}