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)
Forums: