Snowflake connection with Maven, jar on classpath

snowflake jdbc connection string
snowflake jdbc connection timeout
java class not found in classpath net snowflake client jdbc snowflakedriver
snowflake proxy configuration
jdbc proxy
snowflake url

I'm currently trying to make a simple connection to our Snowflake database. I followed the documentation on their site: https://docs.snowflake.net/manuals/user-guide/jdbc-configure.html and verified that the connection string is correct.

Everytime I launch the program, however, I get an SQLException stating it can't find a jar, or that there is no driver found:

[19:28:54] [Server thread/WARN]: driver not found
[19:28:54] [Server thread/WARN]: java.sql.SQLException: No suitable driver found for jdbc:snowflake://d9022.east-us-2.azure.snowflakecomputing.com/
[19:28:54] [Server thread/WARN]:        at java.sql.DriverManager.getConnection(Unknown Source)
[19:28:54] [Server thread/WARN]:        at java.sql.DriverManager.getConnection(Unknown Source)
[19:28:54] [Server thread/WARN]:        at com.mcnations.nationsatwar.jdbc.DatabaseManager.getConnection(DatabaseManager.java:44)
[19:28:54] [Server thread/WARN]:        at com.mcnations.nationsatwar.jdbc.DatabaseManager.init(DatabaseManager.java:50)
[19:28:54] [Server thread/WARN]:        at com.mcnations.nationsatwar.jdbc.DatabaseManager.<init>(DatabaseManager.java:19)
[19:28:54] [Server thread/WARN]:        at net.mcnations.nationsatwar.Player.NationPlayer.<init>(NationPlayer.java:54)
[19:28:54] [Server thread/WARN]:        at net.mcnations.nationsatwar.NationsInitializer.playerLogin(NationsInitializer.java:78)

I use Maven for my dependencies. In my POM, I simply have:

<!-- https://mvnrepository.com/artifact/net.snowflake/snowflake-jdbc -->
        <dependency>
            <groupId>net.snowflake</groupId>
            <artifactId>snowflake-jdbc</artifactId>
            <version>3.9.2</version>
        </dependency>

Even with the Maven dependency stated (in accordance with Snowflake's documentation) I still got the no driver exception. I then added the jar into my build path as well hoping that (maybe) you needed both a maven dependency and an actual .jar file on your build path. This did not fix the problem.

At this point I'm at a loss. I do not know what I am doing wrong, nor do I know how to address it.

My connection class:

package com.mcnations.nationsatwar.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

import net.mcnations.nationsatwar.Player.NationPlayer;

public class DatabaseManager {

    private NationPlayer player;

    public DatabaseManager(NationPlayer player) throws SQLException{
        this.player = player;

        init();

    }

    private static Connection getConnection() throws SQLException{


        try {

            Class.forName("net.snowflake.client.jdbc.SnowflakeDriver");

        }catch(ClassNotFoundException ex) {

            System.err.println("driver not found");
        }

        Properties properties = new Properties();

        properties.put("user", "NationsUser");
        properties.put("password", "//myPassword");
        properties.put("db", "//myDB");
        properties.put("role", "SYSADMIN");

        String connectStr = "jdbc:snowflake://9022.east-us-2.azure.snowflakecomputing.com/";

        return DriverManager.getConnection(connectStr, properties);

    }

    private static void init() throws SQLException{

        Connection connObject = getConnection();

        Statement statement = connObject.createStatement();

        ResultSet rSet = statement.executeQuery("SELECT * FROM PlayerData");

        if(rSet == null) {
            System.out.println("rSet is null");
        }
        else {
            System.out.println(rSet.next());
        }

    }

}

As I understand, you do not deploy the required JAR (snowflake-jdbc-3.9.2.jar) with your application, so it can not find the driver in classpath. Here's similar output when I try to run my application without correct classpath:

java -cp snowflaketest01-1.0-SNAPSHOT.jar com.gokhanatil.snowflaketest01.Main
driver not found
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:snowflake://xxxxxxxxxx.snowflakecomputing.com/
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702)
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:189)
    at com.gokhanatil.snowflaketest01.Main.getConnection(Main.java:28)
    at com.gokhanatil.snowflaketest01.Main.main(Main.java:36)

You may include the JAR by yourself, or you can let Maven pack required the JARs to your final jar. You may include the following to your pom file:

...
    <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
        </configuration>
    </plugin>
...

So it produces one big JAR file which includes all required JAR (snowflake driver etc):

java -cp snowflaketest01-1.0-SNAPSHOT-jar-with-dependencies.jar com.gokhanatil.snowflaketest01.Main

Please check java classpath: https://docs.oracle.com/javase/8/docs/technotes/tools/windows/classpath.html

and including the dependencies in a JAR with Maven: Including dependencies in a jar with Maven

Downloading / Integrating the JDBC Driver — Snowflake , The JDBC driver ( snowflake-jdbc ) is provided as a JAR file, available as an artifact in Maven for download or integrating directly into your Java-based projects. To verify your driver version, connect to Snowflake through a client application� Verifying the Network Connection to Snowflake with SnowCD¶ After configuring your driver, you can evaluate and troubleshoot your network connectivity to Snowflake using SnowCD. You can use SnowCD during the initial configuration process and on-demand at any time to evaluate and troubleshoot your network connection to Snowflake.

The error "java.sql.SQLException: No suitable driver found for java.sql.SQLException: No suitable driver found for jdbc:snowflake://.snowflakecommputing.com" occurs when you try to connect Snowflake database using Java program but either you don't have Snowflake JDBC driver {ex . snowflake-jdbc-3.11.0.jar} in your classpath or driver is not registered before calling the getConnection() method.

Could you please make sure you have included the Snowflake JDBC Driver "snowflake-jdbc-3.11.0.jar" into your Build library path.

How To Connect Snowflake with R/RStudio using JDBC driver on , One needs to follow the below steps to connect Snowflake with R/RStudio Driver link : https://repo1.maven.org/maven2/net/snowflake/snowflake-jdbc/ options(dplyr.jdbc.classpath = "C:\\Driver\\snowflake-jdbc-3.11.1.jar")� You will need to expand the jar file: snowflake-jdbc-3.9.2.jar. The jar file is like a tar ball, but it is a jar ball. You can expand it with jar command, same as tar: jar -xvf snowflake-jdbc-3.9

This error is caused by the application not being able to find the Snowflake jdbc driver. This can happen when jar files have required parameters (ie. config.yml).

Because the Snowflake JDBC driver does not have these required files, I told the main class to launch both itself, and the Snowflake JDBC jar file together via:

@echo off
title Server Console
java -classpath "spigot-1.15.1.jar;lib/*" org.bukkit.craftbukkit.Main
PAUSE

Where the line java -classpath "spigot-1.15.1.jar;lib/*" org.bukkit.craftbukkit.Main states

  1. Start a java application
  2. Down the classpath of "my_main_jar.jar;"
  3. launch with all files in the /lib directory
  4. and point to the main class (in my case, org.bukkit.craftbukkit.Main)

These are command-line arguments that are essentially "handed off" to the application.

Connect Snowflake using Python and Jdbc Driver- Example , Connect Snowflake using Python and Jdbc Driver, Syntax, Example, Snowflake latest version of Snowflake JDBC connector from maven repository. path of those jar files in CLASSPATH shell or environment variable. Now we have Snowflake jdbc driver downloaded and a classpath variable or jar location is set. In this section, we will check Python program that you can use to connect to Snowflake using JDBC driver. Note that, Snowflake jdbc driver class name is “ net.snowflake.client.jdbc.SnowflakeDriver “.

I am using Eclipse and i never faced any such issue .
Create a Maven Project , put dependencies and you are good .

File->New->Project->Maven Project .Give a name to the project ->Finish .

Now add the below dependency.

    <dependency>
            <groupId>net.snowflake</groupId>
            <artifactId>snowflake-jdbc</artifactId>
            <version>3.9.0</version>
        </dependency>

Can you check in your ~/.m2 folder if you are getting the jar or not ?

Connect to Snowflake AWS Cloud Database in Scala using JDBC , Snowflake JDBC driver can be downloaded at the Maven site, download CLASSPATH in simple term, is the path where the jar file is located. Version Repository Usages Date; 3.12.x. 3.12.10: Central: 0 Aug, 2020: 3.12.9: Central: 0 Jul, 2020

Connecting a Jupyter Notebook - Part 4, Create a directory for the snowflake jar files; Define the drivers to be wget "https ://repo1.maven.org/maven2/net/snowflake/$PRODUCT/maven-metadata.xml" you must add the newly installed libraries to the CLASSPATH. The JDBC driver (snowflake-jdbc) is provided as a JAR file, available as an artifact in Maven for download or integrating directly into your Java-based projects.Before downloading or integrating the driver, you may want to first verify the version of the driver you are currently using.

Installing the Snowflake JDBC driver, Namespaces � Connections � Joins � Dependencies � Component To write to Snowflake using SnowflakeWriter, its JDBC driver must be present in the Java classpath for the Striim Download the appropriate Snowflake JDBC driver from https://repo1.maven.org/maven2/net/snowflake/snowflake-jdbc. Step 2: Download the Compatible Version of the Snowflake JDBC Driver¶ Next, you need to download the version of the Snowflake JDBC driver that is compatible with the version of the Snowflake Spark Connnector that you are using. The Snowflake JDBC driver is provided as a standard Java package through the Maven Central Repository.

can not build by maven � Issue #8 � twitter-archive/snowflake � GitHub, The project builds and tests using maven and the small change, but the generated jar doesn't have the Snowflake server, which does get� Using Snowflake Data Warehouse Software with R via dplyr is one of the numerous data warehousing benefits you can unlock with Snowflake. Learn more.

Comments
  • I checked the maven repository of Snowflake client, and it works fine. Do you get this error when you launch the application through your Java IDE or do you get this error after you deploy your application?
  • I get this error only when I deploy the application
  • In this case, maven download the JAR as expected, but you are not deploying all required JARS. At least snowflake driver JAR is missing. Check my detailed answer.
  • This answer did not attempt to offer any solutions at all - you simply stated what I said I had already tried. It SHOULD work in the way you said, but it doesn't. That is why I am asking for help.
  • Its not related to Snowflake jars anyways .Its the way you are building and deploying.