You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafodion.apache.org by "Alice Chen (JIRA)" <ji...@apache.org> on 2015/07/22 20:15:14 UTC

[jira] [Created] (TRAFODION-212) LP Bug: 1301520 - JDBC T4: Unable to make connection by passing props to getConnection

Alice Chen created TRAFODION-212:
------------------------------------

             Summary: LP Bug: 1301520 - JDBC T4: Unable to make connection by passing props to getConnection
                 Key: TRAFODION-212
                 URL: https://issues.apache.org/jira/browse/TRAFODION-212
             Project: Apache Trafodion
          Issue Type: Bug
          Components: client-jdbc-t4
            Reporter: Aruna Sadashiva
            Assignee: kai-hua.xu
            Priority: Critical


Unable to connect to traf using DriverManager.getConnection(String url, Properties prop) overload. It fails with Invalid auth error. getUserConnection works fine with properties from the same prop file.

prop file contents:
catalog=TRAFODION
schema=T2QA
usr=sql_user
pwd=redhat06
url=jdbc:t4jdbc://sq154.houston.hp.com:37800/:
hpjdbc_version=org.trafodion.jdbc.t4.T4Driver
batchBinding=500

code:
    public static String url;
    public static String hpjdbc_version;
    public static String usr;
    public static String pwd;
    public static String catalog;
    public static String schema;
    public static Properties props;

    static
    {
        try
        {
            String propFile = System.getProperty("prop");
            if (propFile != null)
            {
                FileInputStream fs = new FileInputStream(new File(propFile));
                props = new Properties();
                props.load(fs);

                url = props.getProperty("url");
                usr = props.getProperty("usr");
                pwd = props.getProperty("pwd");
                catalog = props.getProperty("catalog");
                schema = props.getProperty("schema");
                hpjdbc_version=props.getProperty("hpjdbc_version");
            } else {
                System.out.println("Error: prop is not set. Exiting.");
                System.exit(0);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            System.out.println(e.getMessage());
        }

        try
        {
	     Class.forName(hpjdbc_version.trim());
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(e.getMessage());
            System.exit(0);
        }
    }

  //------------------------------------------------------------------------
    public static Connection getUserConnection() throws SQLException
    {
       Connection connection = null;
       connection = DriverManager.getConnection(url, usr, pwd);
       return connection;
     }

  //------------------------------------------------------------------------
     public static Connection getPropertiesConnection() throws SQLException
     {
        Connection connection = null;
        connection = DriverManager.getConnection(url, props);
        return connection;
      }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)