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

SNOW-965692: jdbc connector doesn't work for private link #1555

Closed
scardena opened this issue Nov 9, 2023 · 1 comment
Closed

SNOW-965692: jdbc connector doesn't work for private link #1555

scardena opened this issue Nov 9, 2023 · 1 comment
Labels

Comments

@scardena
Copy link

scardena commented Nov 9, 2023

Please answer these questions before submitting your issue.
In order to accurately debug the issue this information is required. Thanks!

  1. What version of JDBC driver are you using?
    snowflake-jdbc-3.14.3.jar

  2. What operating system and processor architecture are you using?
    Amazon linux

  3. What version of Java are you using?

java --version
openjdk 11.0.20 2023-07-18 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.20.0.8-1.amzn2.0.1) (build 11.0.20+8-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.20.0.8-1.amzn2.0.1) (build 11.0.20+8-LTS, mixed mode, sharing)
  1. What did you do?
    Trying to connect to snowflake using jdbc, fails for private link.
    This is the code I am using:
public class SnowflakeJDBCExample {

    public static void main(String[] args) {

        # I replaced the actual endpoint with blabla as it might be sensitive. i didn't actually use blabla as the endpoint. I also modified the error message below for consistency purposes.
        String url = "jdbc:snowflake://app-blabla.privatelink.snowflakecomputing.com/?db=mydb";
        String user = "myuser";
        String password = "mypass";

        try {
            // Load the Snowflake JDBC driver
            Class.forName("net.snowflake.client.jdbc.SnowflakeDriver");

            // Create a connection to Snowflake
            Connection connection = DriverManager.getConnection(url, user, password);

            // Create and execute an SQL query
            Statement statement = connection.createStatement();
            String sqlQuery = "SELECT * FROM mytable";
            ResultSet resultSet = statement.executeQuery(sqlQuery);

            // Process the query results
            while (resultSet.next()) {
                // Retrieve and print data from the result set
                String columnName = resultSet.getString("my_column");
                System.out.println("Column Name: " + columnName);
            }

            // Close the result set, statement, and connection
            resultSet.close();
            statement.close();
            connection.close();
        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }
    }
}

but I a getting the following error when running this:

ava -cp /tmp:/tmp/snowflake-jdbc-3.14.3.jar SnowflakeJDBCExample
Nov 09, 2023 2:39:19 PM net.snowflake.client.jdbc.RestRequest execute
SEVERE: Error response: HTTP Response code: 405, request: POST https://app-blabla.privatelink.snowflakecomputing.com/?db:443/session/v1/login-request?databaseName=mydb&requestId=5e560a81-0264-4790-9a26-6a77d8758633 HTTP/1.1
Nov 09, 2023 2:39:19 PM net.snowflake.client.core.HttpUtil executeRequestInternal
SEVERE: Error executing request: POST https://app-blabla.privatelink.snowflakecomputing.com/session/v1/login-request?databaseName=mydb&requestId=5e560a81-0264-4790-9a26-6a77d8758633 HTTP/1.1
Nov 09, 2023 2:39:19 PM net.snowflake.client.jdbc.SnowflakeUtil logResponseDetails
SEVERE: Response status line reason: Method Not Allowed
Nov 09, 2023 2:39:19 PM net.snowflake.client.jdbc.SnowflakeUtil logResponseDetails
SEVERE: Response content: <html>
<head><title>405 Not Allowed</title></head>
<body>
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx</center>
</body>
</html>

net.snowflake.client.jdbc.SnowflakeSQLException: JDBC driver encountered communication error. Message: HTTP status=405.
        at net.snowflake.client.core.HttpUtil.executeRequestInternal(HttpUtil.java:781)
        at net.snowflake.client.core.HttpUtil.executeRequest(HttpUtil.java:684)
        at net.snowflake.client.core.HttpUtil.executeGeneralRequest(HttpUtil.java:601)
        at net.snowflake.client.core.SessionUtil.newSession(SessionUtil.java:631)
        at net.snowflake.client.core.SessionUtil.openSession(SessionUtil.java:298)
        at net.snowflake.client.core.SFSession.open(SFSession.java:524)
        at net.snowflake.client.jdbc.DefaultSFConnectionHandler.initialize(DefaultSFConnectionHandler.java:112)
        at net.snowflake.client.jdbc.DefaultSFConnectionHandler.initializeConnection(DefaultSFConnectionHandler.java:85)
        at net.snowflake.client.jdbc.SnowflakeConnectionV1.initConnectionWithImpl(SnowflakeConnectionV1.java:116)
        at net.snowflake.client.jdbc.SnowflakeConnectionV1.<init>(SnowflakeConnectionV1.java:96)
        at net.snowflake.client.jdbc.SnowflakeDriver.connect(SnowflakeDriver.java:206)
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
        at SnowflakeJDBCExample.main(SnowflakeJDBCExample.java:21)
  1. What did you expect to see?

the results of the query. using the public snowflake endpoint works fine, so the code works. i assume this is no private link issue, due to getting a 405 instead of a time out or something else networking related.

  1. Can you set logging to DEBUG and collect the logs?

Logs don't seem to be showing any more interesting data than the error message. I can provide those if needed
https://community.snowflake.com/s/article/How-to-generate-log-file-on-Snowflake-connectors

  1. What is your Snowflake account identifier, if any? (Optional)
@scardena scardena added the bug label Nov 9, 2023
@github-actions github-actions bot changed the title jdbc connector doesn't work for private link SNOW-965692: jdbc connector doesn't work for private link Nov 9, 2023
@scardena
Copy link
Author

scardena commented Nov 9, 2023

I noticed I was using the app- endpoint, but I should be using the endpoint without that prefix.

@scardena scardena closed this as completed Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant