Quantcast
Channel: Teradata Downloads - Connectivity
Viewing all articles
Browse latest Browse all 445

Errors obtaining jdbc:default:connection from external Java stored procedure

$
0
0

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);
    rs1.next();
    String resultString = rs1.getString(1);
    stmt.close();
    con.close();

    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))
    LANGUAGE JAVA
    MODIFIES SQL DATA
    PARAMETER STYLE JAVA
    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. 15.0.1.01.
 
Thank you,
Björn
 
[1]: http://www.info.teradata.com/HTMLPubs/DB_TTU_14_00/index.html#page/SQL_Reference/B035_1147_111A/ch05.060.17.html#ww16941705

Forums: 

Viewing all articles
Browse latest Browse all 445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>