Access Hive Metadata using JDBC - java

I am trying to access Hive Metadata using JDBC. I have added all the jar files required in the classpath. I was following the tutorial from here- https://cwiki.apache.org/confluence/display/Hive/HiveClient#HiveClient-JDBC
After adding all the jar files I tried to wrote a sample program to connect to Hive using Java. When I debug the code, as soon as it hit the below line.
Connection con =
DriverManager.getConnection("jdbc:hive://lvsaishdc3in0001.lvs.host.com:10000/
default","", "");
I always get this exception. Not sure why is it happening. Can anyone help me how to fix this problem?
java.sql.SQLException: Could not establish connection to
lvsaishdc3in0001.lvs.host.com:10000/default: java.net.ConnectException: Connection
timed out: connect
I started my Hive sever by logging into Putty and passing the hostname.
$ bash
bash-3.00$ cd /usr/local/bin
bash-3.00$ hive --service hiveserver
Starting Hive Thrift Server
12/07/03 08:07:11 INFO service.HiveServer: Starting hive server on port 10000

Hive server is pretty unsecured by itself. It doesn't eve require username/password for authentication. From my experience, the most typical configuration is to start Hive server on the same box as the application, make sure that this box is connected to the Hadoop cluster and to secure this box. This way your connection string is jdbc:hive://localhost:10000 and the security becomes not your headache, but a headache of your networking folks.

Related

Unable to connect MySQL using R

I'm learning R language. I want to establish a connection with MySQL using R. I've studied how to do from here, here, tutorial and from many other websites. I've followed all the steps to connect with MySQL, but still I'm unable to connect with MySQL, and getting an error:
Error in .local(drv, ...) :
Failed to connect to database: Error: Can't connect to MySQL server on 'localhost' (0)
Here is screenshot of what I did:
I'm using R version-3.2.2 and MySQL version-5.6 and MySQL database is running on localhost:1527. Please help me to remove the error and tell me what I'm doing wrong.
INFO: I'm able to connect above MySQL database with java.
you say that your mysql is running on localhost:1527 - but you don't specify that port in dbConnect, then it probably uses the default port, 3306, so it should not be able to connect... add the port argument to your dbConnect
dbConnect(MySQL(), user="user", password="password", dbname="dbname", host="localhost", port="1527")

The application can't connect with a solr engine on a different computer

I run my Solr engine on Ubuntu 14.04 in VirtualBox. The guest operating system is connect to local network. It has this IP address: 192.168.10.102.
I'm trying to connect with Solr engine using my browser. I'm going to http://192.168.10.102:8983/solr/ and everything is works.
I wrote an application in Java (with SolrJ). I try to connect to the Solr engine and delete everything. The code looks like this:
server = new HttpSolrServer("http://192.168.10.102:8983/solr/");
server.deleteByQuery("*:*");
server.commit();
Sadly I get an exception:
[main] INFO org.apache.solr.client.solrj.impl.HttpClientUtil -
Creating new http client,
config:maxConnections=128&maxConnectionsPerHost=32&followRedirects=false
Exception in thread "main" org.apache.solr.common.SolrException:
Server at http://192.168.10.102:8983/solr returned non ok status:404,
message:Not Found at
org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:372)
at
org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:181)
at
org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:117)
at
org.apache.solr.client.solrj.SolrServer.deleteByQuery(SolrServer.java:285)
at
org.apache.solr.client.solrj.SolrServer.deleteByQuery(SolrServer.java:271)
...
Everything is good when I comment deleteByQuery() and commit() functions.
How can I solve it?
You have to create any collection your url should look like http://192.168.10.102:8983/solr/collection1 and then you can try do something

How do I connect to Derby which is included with WebLogic?

I'm trying to add the Derby included with WebLogic as a data source. I'm running WebLogic 10.3.5. I didn't see a Derby flag in the setDomainEnv.cmd, so I added the client driver to the CLASSPATH:
set CLASSPATH=%PRE_CLASSPATH%;%WEBLOGIC_CLASSPATH%;%POST_CLASSPATH%;%WLP_POST_CLASSPATH%;%WL_HOME%\common\derby\lib\derbyclient.jar
in setDomainEnv.cmd. Now when I try to activate my data source in WebLogic I get:
An error occurred during activation of changes, please see the log for
details. Message icon - Error weblogic.application.ModuleException:
Message icon - Error java.net.ConnectException : Error connecting to
server localhost on port 1527 with message Connection refused:
connect.
What else do I need to do to get this to work?
I believe your local derby is not up yet. To check this, issue:
netstat -an | findstr 1527.
See if it returns anything. If nothing is returned, try to start the Derby Network Service manually. Go to <WLS_HOME>\common\derby\bin and click the startNetworkServer.cmd.
Double check with netstat again. If it's there, you can try to add to the datasource.
Note: this only covers manually start the Derby network service (not automatially start it upon weblogic start, which a bit tricky).
Either whatever is supposed to be running on that port isn't running or there is a firewall issue.

Error connection to herokupostgresql locally

I am writing a struts2 app and using hibernate for persistence. I deploy may app on heroku and everything works ok, but when ever I run it locally I get:
org.postgresql.util.PSQLException: FATAL:no pg_hba.conf entry for host "xx.xx.xxx.xxx", user "someuser", database "somedatabase", SSL off
I know the problem is I need to connect to the database over ssl but how can I set this up locally?
Add this to the end of your JDBC connection URL:
?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
The key here is "SSL off".
You must use SSL to connect to Heroku. How to enable it depends on the client you are using, which I'm guessing is PgJDBC since you're using Java and Hibernate.
The SSL section of the manual for PgJDBC covers what you need.

Connection JDBC SQL Server Error

I've tryed to create a connection with a Microsoft SQl Server 2008 database through JDBC on Eclipse SDK. I've dowloaded JDBC driver from microsoft and I've installed it, then I've added at my System environment variables CLASSPATH the path of sqljdbc4.jar file. After icluding in the Eclipse project the jar file I've tryed to create the connection using:
String connectionUrl = "jdbc:sqlserver://localhost;integratedSecurity=true";
Connection con = DriverManager.getConnection(connectionUrl);
but it doesn't works, and launch me this exception:
com.microsoft.sqlserver.jdbc.SQLServerException: TCP/IP connection
at host localhost, port 1433 failed. Error: "Connection refused:
connect. Verify connection properties and make sure an instance of SQL
Server is running on the host and is accepting TCP/IP connections at
the port. Be sure no firewall blocks connections at the port.
I'm working on a JRE 1.6 so a sqljdbc4 should work, and I've created a working ODBC, so the server is responding, and the error should be in java command or JDBC installation.
Can anyone help me?
At the risk of stating the obvious, this looks to me as if TCP connections haven't been enabled on SQL Server. You have to manually enable them, they don't come enabled by default.
There's an article on MSDN here which explains how to enable TCP protocols for SQL 2005/2008.
Following are the quick trouble shooters:
Try to connect to your server using external front end.
Check if your firewall blocks the connection to the port
Check to see if server is really up.
A Suggestion :
If you are using eclipse , you don't need to add the jar into CLASSPATH variable , you can just add it in library of your project to make it available at runtime

Categories