linkis icon indicating copy to clipboard operation
linkis copied to clipboard

[Bug] Jdbc-driver UJESSQLStatement execute not throw SqlException if a database access error occurs

Open casionone opened this issue 1 year ago • 1 comments

Search before asking

  • [X] I searched the issues and found no similar issues.

Linkis Component

linkis-computation-governance

Steps to reproduce


import java.sql.*;

public class LinkisJDBCTest {

    public static void main(String[] args) throws SQLException, ClassNotFoundException {

        //1. load driver:org.apache.linkis.ujes.jdbc.UJESSQLDriver
        Class.forName("org.apache.linkis.ujes.jdbc.UJESSQLDriver");

        //2. Get Connection:jdbc:linkis://gatewayIP:gatewayPort/dbName?EngineType=hive&creator=test, user/password
        Connection connection =  DriverManager.getConnection("jdbc:linkis://127.0.0.1:9001/default?EngineType=hive&creator=test","test","test");
        //3. Create statement
        Statement st= connection.createStatement();
        String sql="show tablesx";
        try {
            Boolean isok=st.execute(sql);
        } catch (Exception e) {
           e.printStackTrace();
           return;
        }
    }
}

result
Boolean isok=st.execute(sql); will return false should throw SQLException

21:59:53.468 [main] ERROR org.apache.linkis.ujes.jdbc.UJESSQLStatement - 任务执行失败
org.apache.linkis.common.exception.ErrorException: errCode: 42021 ,desc: 您的sql代码可能有语法错误,请检查sql代码 ,ip: null ,port: 0 ,serviceKind: null
        at org.apache.linkis.ujes.jdbc.UJESSQLStatement$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1.apply$mcZ$sp(UJESSQLStatement.scala:155) ~[classes/:?]
        at org.apache.linkis.ujes.jdbc.UJESSQLStatement$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1.apply(UJESSQLStatement.scala:111) ~[classes/:?]
        at org.apache.linkis.ujes.jdbc.UJESSQLStatement$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1.apply(UJESSQLStatement.scala:111) ~[classes/:?]
        at org.apache.linkis.ujes.jdbc.UJESSQLStatement$$anonfun$throwWhenClosed$1.apply(UJESSQLStatement.scala:49) ~[classes/:?]
        at org.apache.linkis.ujes.jdbc.UJESSQLConnection.throwWhenClosed(UJESSQLConnection.scala:109) ~[classes/:?]
        at org.apache.linkis.ujes.jdbc.UJESSQLStatement.throwWhenClosed(UJESSQLStatement.scala:47) ~[classes/:?]
        at org.apache.linkis.ujes.jdbc.UJESSQLStatement$$anonfun$execute$1.apply$mcZ$sp(UJESSQLStatement.scala:111) ~[classes/:?]
        at org.apache.linkis.ujes.jdbc.UJESSQLStatement$$anonfun$execute$1.apply(UJESSQLStatement.scala:111) ~[classes/:?]
        at org.apache.linkis.ujes.jdbc.UJESSQLStatement$$anonfun$execute$1.apply(UJESSQLStatement.scala:111) ~[classes/:?]
        at org.apache.linkis.common.utils.Utils$.tryCatch(Utils.scala:48) ~[classes/:?]
        at org.apache.linkis.ujes.jdbc.UJESSQLStatement.execute(UJESSQLStatement.scala:190) ~[classes/:?]
        at org.apache.linkis.ujes.jdbc.LinkisJDBCTest.main(LinkisJDBCTest.java:23) ~[test-classes/:?]
Disconnected from the target VM, address: '127.0.0.1:4497', transport: 'socket'

Expected behavior

none

Your environment

  • Linkis version used: 1.1.2
  • Environment name and version:
    • cdh-5.14.2
    • hdp-3.1.5
    • hive-2.1.1
    • spark-3.2.1
    • scala-2.12.2
    • jdk 1.8.0_121
    • ....

Anything else

No response

Are you willing to submit a PR?

  • [ ] Yes I am willing to submit a PR!

casionone avatar Mar 14 '23 14:03 casionone