Skip to content

Add support for sybase tds jdbc driver #8764

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

Merged
merged 6 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ DBInfo.Builder doParse(final String jdbcUrl, final DBInfo.Builder builder) {
}

String path = uri.getPath();
if (path.startsWith("/")) {
path = path.substring(1);
}
if (!path.isEmpty()) {
builder.db(path);
// a URI can have a null path
if (path != null) {
if (path.startsWith("/")) {
path = path.substring(1);
}
if (!path.isEmpty()) {
builder.db(path);
}
}

if (uri.getHost() != null) {
Expand Down Expand Up @@ -795,7 +798,23 @@ DBInfo.Builder doParse(String jdbcUrl, DBInfo.Builder builder) {
}
return GENERIC_URL_LIKE.doParse(url, builder);
}
};
},
// https://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc01776.1601/doc/html/san1357754914053.html
// Sybase TDS
SYBASE_TDS("sybase") {
@Override
DBInfo.Builder doParse(String jdbcUrl, DBInfo.Builder builder) {
if (jdbcUrl.startsWith("sybase:tds:")) {
// that uri is opaque so we need to adjust it in order to be parsed with the classical
// hierarchical way
return GENERIC_URL_LIKE
.doParse("sybase://" + jdbcUrl.substring("sybase:tds:".length()), builder)
.subtype("tds");
}
return GENERIC_URL_LIKE.doParse(jdbcUrl, builder);
}
},
;

private static final Map<String, JDBCConnectionUrlParser> typeParsers = new HashMap<>();

Expand Down Expand Up @@ -925,6 +944,9 @@ private static void populateStandardProperties(
ExceptionLogger.LOGGER.debug("Error parsing portnumber property: {}", portNumber, e);
}
}
if (props.containsKey("servicename")) {
builder.instance((String) props.get("servicename"));
}

if (props.containsKey("portNumber")) {
final String portNumber = (String) props.get("portNumber");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class DefaultConnectionInstrumentation extends AbstractConnectionInstrume
"com.informix.jdbc.IfmxConnection",
// Intersystems IRIS
"com.intersystems.jdbc.IRISConnection",
// Sybase
"com.sybase.jdbc4.jdbc.SybConnection",
// for testing purposes
"test.TestConnection"
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ public final class PreparedStatementInstrumentation extends AbstractPreparedStat
// Intersystems IRIS
"com.intersystems.jdbc.IRISPreparedStatement",
"com.intersystems.jdbc.IRISCallableStatement",
// sybase
"com.sybase.jdbc4.jdbc.SybPreparedStatement",
// for testing purposes
"test.TestPreparedStatement"
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ class JDBCConnectionUrlParserTest extends AgentTestRunner {
"jdbc:IRIS://dbhostname:1972/namespace" | null | "iris" | null | null | "dbhostname" | 1972 | null | "namespace"
"jdbc:IRIS://dbhostname:1972/namespace/+myjdbc.log" | null | "iris" | null | null | "dbhostname" | 1972 | null | "namespace"
"jdbc:IRIS://dbhostname:1972/namespace/::false" | null | "iris" | null | null | "dbhostname" | 1972 | null | "namespace"

// sybase
"jdbc:sybase:Tds:dbhostname:2638?ServiceName=demo" | null | "sybase" | "tds" | null | "dbhostname" | 2638 | "demo" | null
"jdbc:sybase:Tds:dbhostname:2638/dbname" | null | "sybase" | "tds" | null | "dbhostname" | 2638 | null | "dbname"
expected = new DBInfo.Builder().type(type).subtype(subtype).user(user).instance(instance).db(db).host(host).port(port).build()
}
}
Loading