我編寫了一個Java存儲過程,將它打包到jar中並將其安裝到Teradata數據庫中。我想使用here所述的默認數據庫連接。大部分代碼是由Teradata嚮導爲存儲過程生成的。Teradata外部Java存儲過程錯誤:找不到適用於jdbc的驅動程序:默認:連接
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;
}
}
我安裝的jar:
CALL SQLJ.REPLACE_JAR('CJ!/my/path/Teradata-SqlTest.jar','test');
,並建立了過程:
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[])';
現在,當我把這個過程中,我得到這個錯誤信息:
Executed as Single statement. Failed [7827 : 39001] Java SQL Exception SQLSTATE 39001: Invalid SQL state (08001: No suitable driver found for jdbc:default:connection).
現在我從Terada註銷ta並再次登錄並調用該過程,錯誤消息變爲:
Executed as Single statement. Failed [7827 : 39001] A default connection for a Java Stored Procedure has not been established for this thread.).
這裏有什麼問題?我使用Eclipse插件連接到Teradata。 Teradata訴15.0.1.01。