yuluo-yx commented on code in PR #19:
URL: 
https://github.com/apache/hertzbeat-collector-go/pull/19#discussion_r2384213624


##########
internal/collector/basic/database/jdbc_collector.go:
##########
@@ -234,14 +254,13 @@ func (jc *JDBCCollector) constructDatabaseURL(jdbc 
*jobtypes.JDBCProtocol) (stri
 func (jc *JDBCCollector) getConnection(databaseURL, username, password string, 
timeout time.Duration) (*sql.DB, error) {
        // Extract driver name from URL
        var driverName string
-       if strings.HasPrefix(databaseURL, "mysql://") {
-               driverName = "mysql"
-               // Remove mysql:// prefix for the driver
-               databaseURL = strings.TrimPrefix(databaseURL, "mysql://")
-       } else if strings.HasPrefix(databaseURL, "postgres://") {
+       if strings.HasPrefix(databaseURL, "postgres://") {
                driverName = "postgres"
        } else if strings.HasPrefix(databaseURL, "sqlserver://") {
                driverName = "sqlserver"
+       } else if strings.Contains(databaseURL, "@tcp(") {
+               // MySQL DSN format (no protocol prefix)
+               driverName = "mysql"

Review Comment:
   抽成 常量定义 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to