Hive-Java(jdbc) connection problems - java

I'm trying to connect with hive via jdbc but it gives me the following exception
java.sql.SQLException: org.apache.thrift.transport.TTransportException
I already have running hadoop and derby. By the console of hive (in linux) I can work but once I try it for the project in java it does not work
Class.forName("org.apache.hadoop.hive.jdbc.HiveDriver");
Connection co = DriverManager.getConnection("jdbc:hive://localhost:9000/almacendb", "","");

Related

JDBC can't connect to SQL Server / Azure SQL Database

I use
JTDS version: jtds-1.3.1
MS SQL JDBC version: mssql-jdbc-8.4.0.jre8 even mssql-jdbc-9.2.0.jre8
Java 8 Update 251
For simplicity, the code will the same as:
Android studio can't connect to database in Azure sql server
I have a problem to connect to SQL Server or Azure SQL.
I want to connect with this syntax:
val connectionString = "jdbc:jtds:sqlserver://192.168.xx.xx:1433;databaseName=myData;user=x1;password=p1;encrypt=true;trustServerCertificate=true;"
With this JTDS connection string, I can connect to my SQL Server DB on localhost, but with MS-JDBC, I failed to connect.
val connectionString = "jdbc:sqlserver://192.168.xx.xx:1433;databaseName=myData;user=x1;password=p1;encrypt=true;trustServerCertificate=true;"
I get the following errors:
com.microsoft.sqlserver.jdbc.SQLServerException: The Driver could not
establish a secured connection to SQL Server by using Secure Sockets
Layer (SSL) encryption. Error: "Socket is closed". ClientConnectionId:
xxxxxxxxxxxxxxxxx
An interesting thing happens when I connect with JTDS version to SQL Azure with the command:
jdbc:jtds:sqlserver://xxxxx.database.windows.net:1433;database=xxxxx;user=username;password=password;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
I failed to connect to SQL Azure with the following errors
java.sql.SQLException: Reason: Login Failed due to client TLS Version
being less than minimal TLS Version allowed by the server
I already tried:
SSLProtocol=TLSv1.2 (TLS, TLSv1.0, TLSv1.1) => none work
ssl=require
Is it a bug with JTDS, a bug with JDBC, o isr my connection string invalid? I can connect to SQL Azure with my dotnet apps (C#).
I just fixed this in an Azure Managed Instance using the PowerShell script below:
Set-AzSqlInstance -Name 'InstanceName' -ResourceGroupName 'ResourceGroupName' -MinimalTlsVersion "None" -force

Socket write error with activejdbc

I have a pretty simple commandline app that runs inside of eclipse that connects to an Oracle 12 database and issues a pretty simple query. I'm getting the following exception:
Exception in thread "main" org.javalite.activejdbc.InitException: Failed to connect to JDBC URL: jdbc:oracle:thin:#oratest2a.emspic.org:1521:workstst
at org.javalite.activejdbc.DB.open(DB.java:93)
at org.javalite.activejdbc.Base.open(Base.java:64)
at org.emspic.works.RegistrationUtil.doMain(RegistrationUtil.java:135)
at org.emspic.works.RegistrationUtil.main(RegistrationUtil.java:75)
Caused by: java.sql.SQLRecoverableException: IO Error: Connection reset by peer: socket write error
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:752)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:666)
Code throwing the exception is basically this:
// use properties to open the datasource for work
System.out.println("Opening database connection.");
logger.info("Opening database");
String dbDriver = dbProps.get("dbDriver");
String dbURL = dbProps.get("dbURL");
String username = dbProps.get("username");
String password = dbProps.get("password");
Base.open(dbDriver, dbURL, username, password);
logger.info("Database successfully opened.");
Everything I've googled indicates the problem is a "network issue"...except that on this same machine, I am currently connected to the very table I'm trying to open via TOAD...and I also am running a jboss as server connecting to that very same database...so there is no way it is a network problem.
I'm at a total loss.
Java1.8, ojdbc7.jar, all running on a Microsoft Surface Pro 3..., Oracle version is 12.0.2 running remotely.
Your exception has nothing to do with AcitveJDBC. There is a problem with your Oracle configuration. I bet you will get the same exception if you try just JDBC with the same parameters. When/if you fix your issue with JDBC, ActiveJDBC will work just fine.

JDBC connection to hive fails

I'm trying to establish a JDBC connection to Hive so that I can query Hive tables using java API for hive 0.13.1. I've tried connecting to HiveServer1 and HiverServer2 but unable to make connection.
However locally within the box I am able to connect to the server using beeline command following it up with the command:
!connect jdbc://hive2://
once connection is established I am able to view the tables using command:
show tables;
However the same thing when I try from a remote m/c using java api it fails. Here is the code snippet that is failing.
Connection con = DriverManager.getConnection("jdbc:hive2://RHDCN05.rmsi.com:10000", "", "");
Statement stmt = con.createStatement();
Hope somebody can help in figuring out the problem.
Any help would be appriciated!!!

Getting JDBC drivers compatibility issue. java.sql.SQLException: ORA-06413: Connection not open

I am getting below exception with Oracle JDBC ojdbc14_g.jar drivers:
java.sql.SQLException: ORA-06413: Connection not open.
My Oracle version is:
My machine and server details are:
I am able to connect to production DB from my development environment, but after installing application in production server my application is unable to connect to locally installed database. I am getting above said exception.
Below is my connection URL:
jdbc:oracle:oci8:#127.0.0.1:1521:XE
Try to replace oci8 with thin. JDBC over (native) OCI require some knowledge and experience. You have to install and configure Oracle client 1st.
See http://docs.oracle.com/cd/B28359_01/java.111/b31224/instclnt.htm

Unable to Connect to Oracle Database 11g via JDBC

I am not able to connect to oracle Database from my machine , but can connect to same DB through SQL developer. I am getting the following exception
java.sql.SQLRecoverableException: IO Error: Connection reset by peer:
socket write error at
oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:428) at
oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:536)
at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:228)
at
oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521) at
oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:280)
at
oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:207)
at
oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:157)
at OrgHierarchy.DBTest.main(DBTest.java:39)
I can also telnet to same DB URL and port.
Other Details: Windows XP , Oracle 11g 11.0.2
thanks.

Categories

Resources