Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rcca-9158: Connector fails to populate TableTypes with Sybase JConnect driver #1259

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ravib777
Copy link

Problem

JDBC Source connector when used with JConnect driver for AES DB, it fails to create the connector with the following error:

com.sybase.jdbc4.jdbc.SybSQLException: '""' is not a valid type name.
at com.sybase.jdbc4.tds.Tds.processEed(Tds.java:4003)
at com.sybase.jdbc4.tds.Tds.nextResult(Tds.java:3093)
at com.sybase.jdbc4.jdbc.ResultGetter.nextResult(ResultGetter.java:78)
at com.sybase.jdbc4.jdbc.SybStatement.nextResult(SybStatement.java:289)
at com.sybase.jdbc4.jdbc.SybStatement.nextResult(SybStatement.java:271)
at com.sybase.jdbc4.jdbc.SybStatement.queryLoop(SybStatement.java:2408)
at com.sybase.jdbc4.jdbc.SybCallableStatement.executeQuery(SybCallableStatement.java:146)
at com.sybase.jdbc4.jdbc.SybDatabaseMetaData.returnResults(SybDatabaseMetaData.java:4324)
at com.sybase.jdbc4.jdbc.SybDatabaseMetaData.getTables(SybDatabaseMetaData.java:3010)
at io.confluent.connect.jdbc.dialect.GenericDatabaseDialect.tableIds(GenericDatabaseDialect.java:428)
at io.confluent.connect.jdbc.source.TableMonitorThread.updateTables(TableMonitorThread.java:175)
at io.confluent.connect.jdbc.source.TableMonitorThread.run(TableMonitorThread.java:85)

The issue is reported earlier here:
https://forum.confluent.io/t/jdbc-source-connector-for-sybase-com-sybase-jdbc4-jdbc-sybsqlexception-is-not-a-valid-type-name/2256

It looks like JConnect driver returns values for DatabaseMetaData.getTableTypes() with trailing spaces:
image

Solution

Although this looks like JConnect driver bug, the connector can handle this behavior by trimming the trailing spaces to get the absolute value returned from the DB.

Does this solution apply anywhere else?
  • yes
  • [x ] no
If yes, where?

Test Strategy

Testing done:
  • Unit tests
  • Integration tests
  • System tests
  • [ x] Manual tests

Release Plan

@ravib777 ravib777 requested a review from a team as a code owner October 25, 2022 23:21
@CLAassistant
Copy link

CLAassistant commented Oct 25, 2022

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -464,7 +464,7 @@ protected String[] tableTypes(
Set<String> matchingTableTypes = new HashSet<>();
try (ResultSet rs = metadata.getTableTypes()) {
while (rs.next()) {
String tableType = rs.getString(1);
String tableType = rs.getString(1).trim();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ravib777 As mentioned here; let's keep this as a last resort option. But since you have taken a stab at it and raised the PR; I had a look at the same and have following comments:

  1. If you see line 468 has a null check viz. "tableType != null" so now calling trim() before that null check can lead to a NPE. Please handle that null scenario.
  2. I see that master branch has this line of code on line#490; whereas I see your PR shows that as line 467! I am not sure why. Can you please double check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants