Problem Authenticating through JDBC running on Linux.

Connectivity

Problem Authenticating through JDBC running on Linux.

Hi all,

I am trying to connect to Teradata Database 14 using the Teradata JDBC 14 driver.  The Java code is running on a Linux server using Ubuntu 12 and JVM 6 (64-bit).  I keep getting the following error....

com.teradata.jdbc.jdbc_4_util.JDBCException: [Teredata Database] [TeraJDBC 14.00.00.14] [Error 8017] [SQLState 28000] The UserId, Password or Account is invalid.

Here is the relevent Java code that I'm running (with the * replaceing the actual IP, User and Password)....

Connection dbConn = null;

String driver = "com.teradata.jdbc.TeraDriver";
String conUrl = "jdbc:teradata://***.**.*.***/USER=********,PASSWORD=*****";

Class.forName(driver).newInstance();

dbConn = DriverManager.getConnection(conUrl);

This exact same code works while running it on my Windows based PC using Eclipse.

Any Ideas?

Thanks,

8 REPLIES
Teradata Employee

Re: Problem Authenticating through JDBC running on Linux.

The newInstance method call is not required.

There should not be a space between the slash following the IP address and the USER= property.

You should specify the COP=OFF property when you specify an IP address for the Teradata Database.

String driver = "com.teradata.jdbc.TeraDriver";

String conUrl = "jdbc:teradata://111.22.3.111/COP=OFF,USER=joe,PASSWORD=secret";

Class.forName(driver);

Connection dbConn = DriverManager.getConnection(conUrl);

If you continue to have a problem, and you are a customer, then please open an incident with Customer Support.

 

Re: Problem Authenticating through JDBC running on Linux.

The space before the user parameter was not acutally in the Java code, not sure how it got into the post.

I removed the newInstance call and added the COP=OFF parameter and still received the same error while running it on the Linux server. I've tried a number of different combinations of parameters from examples I've seen on-line.  All of these examples worked while running the Java from my PC in Eclipse, but received the same error on the Linux server.

I've also tested this code on the Linux box with a different JDBC driver (DB2) and it worked fine.  I'm wondering if there is some Linux setting that may need to be changed or some special connection parameter needed.

We are not a customer yet, we are evauluating Teradata along with a few other datawarehouse solutions.  I think our Teradata contact is in the process of opening up an incident with Customer Support, but I was hoping to figure this out asap.

Enthusiast

Re: Problem Authenticating through JDBC running on Linux.

 private static String user = "tduser";
private static String password = "passwd";
private static String url = "jdbc:teradata://TDServer/TMODE=ANSI,CHARSET=UTF8";
private String sqlGetData = "SELECT * FROM dbc.tables WHERE databasename='<dbname>'";

public static void getData(String sqlGetData) {
Statement statement = null;
Connection connection = null;
ResultSet resultSet = null;

try {
Class.forName("com.teradata.jdbc.TeraDriver");
connection = DriverManager.getConnection(url, user, password);
statement = connection.createStatement();
resultSet = statement.executeQuery(sqlGetData);

ResultSetMetaData resultSetMetaData = resultSet.getMetaData();

int columnCount = resultSetMetaData.getColumnCount();
for (int i=1; i<=columnCount; i++) {
System.out.print(resultSetMetaData.getColumnName(i).toUpperCase() + ",");
}

System.out.println("");

while (resultSet.next()) {
for (int i=1; i<=columnCount; i++) {
System.out.print(resultSet.getString(i) + ",");
}

System.out.println("");
}
}
catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
}
finally {
if (statement != null) {
try {
statement.close();
}
catch (SQLException e) {
e.printStackTrace();
}
}
if (connection != null) {
try {
connection.close();
}
catch (SQLException e) {
e.printStackTrace();
}
}
}
}

Enthusiast

Re: Problem Authenticating through JDBC running on Linux.

in your linux server, add an entry in /etc/hosts file for this ip address and use it in the connection url.

111.22.3.111 myTDServer

New Member

Re: Problem Authenticating through JDBC running on Linux.

HI Am using below code to establish JDBC connection am not able to connect when am running it from my linux machine , drivers are 16.00.00.32

 

private static String user = "********";
private static String password = "********";
private static String url = "jdbc:teradata://1*********/tmode=ANSI,charset=UTF8";
public static void main(String[] args) throws IOException, ClassNotFoundException {
try {

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

Connection Conn = DriverManager.getConnection(url,user,password);

String query = "select * from employee"; // 911

PreparedStatement stmt = Conn.prepareStatement(query);
ResultSet rs = stmt.executeQuery();

 

 

 

error :

 

java.lang.ClassNotFoundException: com.teradata.jdbc.TeraDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.fd.oip.cc.controller.CKSManager.main(CKSManager.java:71)
java.lang.ClassNotFoundException: com.teradata.jdbc.TeraDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.fd.oip.cc.controller.CKSManager.main(CKSManager.java:122)

Teradata Employee

Re: Problem Authenticating through JDBC running on Linux.

Please create a new thread for a new question. Please do not necro an old thread from 2012.

 

Your exception "ClassNotFoundException: com.teradata.jdbc.TeraDriver" indicates that you do not have terajdbc4.jar on your classpath.

 

Please refer to the relevant section of the Teradata JDBC Driver User Guide: http://developer.teradata.com/doc/connectivity/jdbc/reference/current/jdbcug_chapter_2.html#BGBGGJHC

 

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

New Member

Re: Problem Authenticating through JDBC running on Linux.

Hi, I have both the jars in my classpath, still could not counnect?

Teradata Employee

Re: Problem Authenticating through JDBC running on Linux.

I understand that you believe that you have the jar files on your classpath, but the exception message indicates that you do not have terajdbc4.jar on your classpath.