All Forums Connectivity
bjacobs 3 posts Joined 03/16
21 Mar 2016
Errors obtaining jdbc:default:connection from external Java stored procedure

I wrote a Java stored procedure, packed it into a jar and installed it into the Teradata database. I want to use the default database connection as described here [1]. Most of the code was generated by the Teradata wizard for stored procedures.

public class TestSql {
    public static void getEntryById(int id, String[] resultStrings) throws SQLException {
        Connection con = DriverManager.getConnection("jdbc:default:connection") ;

    String sql = "SELECT x FROM TEST_TABLE WHERE ID = " + id + ";";

    Statement stmt = (Statement) con.createStatement();
    ResultSet rs1 = ((java.sql.Statement) stmt).executeQuery(sql);;
    String resultString = rs1.getString(1);

    resultStrings[0] = resultString;

I installed the jar:

CALL SQLJ.REPLACE_JAR('CJ!/my/path/Teradata-SqlTest.jar',' test');

And created the procedure:

REPLACE PROCEDURE "db"."getEntryById" (
    IN "id" INTEGER,
    OUT "resultString" VARCHAR(1024))
    EXTERNAL NAME 'test: my.package.TestSql.getEntryById(int,java.lang.String[] )';

Now when I call this procedure, I get this error message:

Executed as Single statement.  Failed [7827 : 39001] Java SQL Exception SQLSTATE 39001: Invalid SQL state (08001: No suitable driver found for jdbc:default:connection).

Now when I log off from Teradata and log on again and call the procedure, the error message becomes:

Executed as Single statement.  Failed [7827 : 39001] A default connection for a Java Stored Procedure has not been established for this thread.).

What is the problem here? I'm connecting to Teradata using the Eclipse plugin. Teradata v.
Thank you,
[1]: index.html#page/SQL_Reference/B035_1147_111A/ ch05.060.17.html#ww16941705

bjacobs 3 posts Joined 03/16
22 Mar 2016

After many hours I finally found the problem. Eclipse packed all dependencies into the jar - which basically is ok. However it also packed the Teradata JDBC driver files (tdgssconfig.jar and terajdbc4.jar) into the result jar, which was the problem.
I adjusted the jar building process so that these files are not included and the errors went away.


tomnolan 594 posts Joined 01/08
22 Mar 2016

Correct -- you should not include terajdbc4.jar and tdgssconfig.jar within your jar file that contains your stored procedure.

You must sign in to leave a comment.