Menu

Connecting to Vertica using JDBC

Help
2014-08-11
2014-08-14
  • Floyd Moore

    Floyd Moore - 2014-08-11

    Hello,

    I am trying to connect to the Profiler tool with a Vertica Database. I have been able to connect using the ODBC connection and to connect to the database with a small java program using jdbc. However, I cannot identify all of the required fields on the connection page to fill them in for my database. Can you provide more information as to what these connection strings mean using a standard java jdbc connect statement as a start?

    import java.sql.*;
    import java.util.Properties;
    public class ConnectionExample {

    public static void main(String[] args) {
        // Load JDBC driver
        try {
            Class.forName("com.vertica.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            // Could not find the driver class. Likely an issue
            // with finding the .jar file.
            System.err.println("Could not find the JDBC driver class.");
            e.printStackTrace();
            return; // Bail out. We cannot do anything further.
        }
        // Create property object to hold username & password
    
        Properties myProp = new Properties();
        myProp.put("user", "username");
        myProp.put("password", "mypass");
        Connection conn;
    
        try {
            conn = DriverManager.getConnection(
                       "jdbc:vertica://hostname.com:5433/dbname", myProp);
        } catch (SQLException e) {
            // Could not connect to database.
            System.err.println("Could not connect to database.");
            e.printStackTrace();
            return;
        }
    }
    

    }

    Thanks!

     
    • arrah

      arrah - 2014-08-14

      Thanks for your interest in osDQ. For jdbc please select
      Db type - others jdbc
      Do name - //hostname.com:5443/dbname
      Username - username
      Password - mypass
      Driver - com.vertica.jdbc.Driver
      Protocol - jdbc:vertica

      Make sure the jar file that contains the driver is in class path. You
      should be able to connect using above parameters. If you have any issue
      please let me know.

      Regards,
      Vivek

      On Monday, August 11, 2014, Floyd Moore feksmoore@users.sf.net wrote:

      Hello,

      I am trying to connect to the Profiler tool with a Vertica Database. I
      have been able to connect using the ODBC connection and to connect to the
      database with a small java program using jdbc. However, I cannot identify
      all of the required fields on the connection page to fill them in for my
      database. Can you provide more information as to what these connection
      strings mean using a standard java jdbc connect statement as a start?

      import java.sql.*;
      import java.util.Properties;
      public class ConnectionExample {

      public static void main(String[] args) {
      // Load JDBC driver
      try {
      Class.forName("com.vertica.jdbc.Driver");
      } catch (ClassNotFoundException e) {
      // Could not find the driver class. Likely an issue
      // with finding the .jar file.
      System.err.println("Could not find the JDBC driver class.");
      e.printStackTrace();
      return; // Bail out. We cannot do anything further.
      }
      // Create property object to hold username & password

      Properties myProp = new Properties();
      myProp.put("user", "username");
      myProp.put("password", "mypass");
      Connection conn;
      
      try {
          conn = DriverManager.getConnection(
                     "jdbc:vertica://hostname.com:5433/dbname", myProp);
      } catch (SQLException e) {
          // Could not connect to database.
          System.err.println("Could not connect to database.");
          e.printStackTrace();
          return;
      }}
      

      }

      Thanks!

      Connecting to Vertica using JDBC
      https://sourceforge.net/p/dataquality/discussion/602692/thread/c2f733ec/?limit=25#19f1


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/dataquality/discussion/602692/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      reagrds,
      Vivek
      Author of "The Reverse Journey" from Frogbooks

       

Log in to post a comment.

Auth0 Logo