I have a deployed Cassandra DB that I've been trying to connect to but I get the below error message:
Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: <ipaddress_here>:<port_here> (com.datastax.driver.core.exceptions.TransportException: [<ipaddress_here>:<port_here> ] Cannot connect))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:232)
at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:79)
at com.datastax.driver.core.Cluster$Manager.negotiateProtocolVersionAndConnect(Cluster.java:1631)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1549)
at com.datastax.driver.core.Cluster.init(Cluster.java:160)
at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:342)
at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:317)
at com.datastax.driver.core.Cluster.connect(Cluster.java:259)
at org.springframework.cassandra.config.CassandraCqlClusterFactoryBean.executeSpecsAndScripts(CassandraCqlClusterFactoryBean.java:327)
at org.springframework.cassandra.config.CassandraCqlClusterFactoryBean.afterPropertiesSet(CassandraCqlClusterFactoryBean.java:243)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
The <ipaddress_here>:<port_here> snippet in the error is actually my valid ip and port that I'm expecting but was removed for obvious reasons. I've had Cassandra working on my local and the permissions on the remote Cassandra are correct since a colleague can successfully connect to the keyspace.
I've seen extending the timeout and this post about the native connections but don't know what else to try.
My Cassandra config is setup similar to this.
The port I am using is different from the default 9042 and 9160 that I've seen on the boards elsewhere. I also used 9042 when I connected on my localhost.
Any help is appreciated including how to get better error logs!
Is there a proxy I would have to set if I'm behind one?
Related
I am getting this error in my stacktrace of my Java Spring app:
Caused by: com.mongodb.MongoConfigurationException: Unable to look up TXT record for host <endpoint>.mongodb.net
[...]
javax.naming.NameNotFoundException: DNS name not found [response code 3]
I can verify that I can connect to this MongoDB via Robo3T with the exact same connection string but when I run this app, I get this error.
My Spring Boot version is: 2.6.6. And the dependency for Spring Data is: org.springframework.boot:spring-boot-starter-data-mongodb:2.6.6.
Things I've tried:
The issue I'm running into is very similar to this SO post. I tried updating my local Windows firewall to allow for those inbound/outbound ports (and restarted my machine) but no dice.
I then tried to update my DNS settings to use Google's 8.8.8.8 on my Windows network adapter for IPv4 but also no dice.
I also saw this fixed issue about the Java Mongo driver throwing the exact same exception above, https://jira.mongodb.org/browse/JAVA-4018. So I then tried to update my Spring Data Mongo dependencies to v2.7.0 but also no dice.
Any other suggestions?
I am trying to parse a CSV file and create nodes and edges into Cosmos db via the help of gremlin-java client ( https://github.com/Azure-Samples/azure-cosmos-db-graph-java-getting-started ).
Some queries I have changed in this program:
For adding data :
Submitting this Gremlin 87246 query:
g.V().has('id','1120-L CONSOLIDATED SCHEDULE L').fold().coalesce(unfold(), addV('sub_schedule').property('id', '1120-L CONSOLIDATED SCHEDULE L').property('name', '1120-L CONSOLIDATED SCHEDULE L'))
For Creating edge:
g.V().hasLabel('parent').has('id', '1120').addE('has').to(g.V().hasLabel('state').has('id', 'FD'))
After running it almost for 6 hours successfully it gives weird error:
Exception in thread "main" java.util.concurrent.ExecutionException: java.io.IOException: An existing connection was forcibly closed by the remote host
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at GetStarted.WriteWithOriginalCSVData.main(WriteWithOriginalCSVData.java:158)
Caused by: java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:192)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:221)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:899)
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:275)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:119)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:652)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:575)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:489)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:451)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
at java.lang.Thread.run(Thread.java:745)
Can somebody please tell me the possible causes for this?
To mention I am invoking this java client remotely from my laptop via open connection and hitting azure services ( in different location ).
Firstly I thought it might be because of my internet connectivity . But it exactly throws error when it has completed some 87-88k gremlin queries.
Can someone please let me know where I am going wrong here?
I am trying to connect to a database on my localhost machine from Eclipse using the JPA tools. I have been unable to achieve this so far. I want to create a JPA project and create the model from the tables that I have already created on the database. I do not seem to be able to get the connection string correct.
firstly I seem completely unable to create a SQL Server connection profile. Once I get to the second screen no options available that allow me to progress past it to completion. Found a thread on here that claimed this is a bug and I should use the generic driver instead. So this is what I tried.
I thought that the port number was 1433 and I have tried that but no change. I have also taken off the (localdb) part as the error message referenced it. Message remains the same.
Error Message
com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the host (localdb), named instance mssqllocaldb failed. Error: "java.net.UnknownHostException: (localdb)". Verify the server and instance names and check that no firewall is blocking UDP traffic to port 1434. For SQL Server 2005 or later, verify that the SQL Server Browser Service is running on the host.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:191)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.getInstancePort(SQLServerConnection.java:5247)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.primaryPermissionCheck(SQLServerConnection.java:1871)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1608)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1459)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:773)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1168)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:328)
at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105)
at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:96)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnectionFactory.createConnection(JDBCConnectionFactory.java:53)
at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)
at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:359)
at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)
at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
I got the connection string from Visual studio as that is how I created the tables.
Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=IdpValidate;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
I have checked the firewall on my machine but Eclipse is in there and I can connect no problems from Visual Studio so it can't be that (can it).
SQL Server Agent and SQL Server Browser are both on (again I can connect from elsewhere; mssms, vs, linqpad etc) Please help this is driving me mad!
I have also created a login and user (LetMeIn) but at the moment this is not making a diffrence as using my computer account can't connect through Eclsipe either.
It turns out I have two sql servers installed on my machine and I was trying to connect to the wrong one. :(
I have a working Spring Boot app (1.2) that uses Postgres. Today I am trying to switch it to Oracle, but when I try to connect I get an exception that says:
java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
And below that,
Caused by: java.net.ConnectException: Connection refused
So of course that looks like bad credentials, but I know they are good, and they are working in Oracle SQL Developer just fine. I'm baffled. Here are my properties file entries:
# Properties for Hibernate and Oracle
spring.datasource.driverClassName=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:#//earth-db-11:5121/stardev
spring.datasource.username=ops$abcdefg
spring.datasource.password=mypassword
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
The only idea I have is that there is a $ in the user name, and I have tried escaping it and putting double quotes around it.
Any ideas?
Thanks...
UPDATE:
Many thanks to BonanzaOne, I did have the port number wrong. Correcting that results in a new error:
java.sql.SQLRecoverableException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
I looked it up of course, but I don't follow what its telling me:
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Cause: The listener received a request to establish a connection to a database
or other service. The connect descriptor received by the listener specified a
service name for a service (usually a database service) that either has not yet
dynamically registered with the listener or has not been statically configured
for the listener. This may be a temporary condition such as after the listener
has started, but before the database instance has registered with the listener.
Still, SQL Explorer connects fine.
That exception means that the Oracle listener is not up, or you are trying to connect to a listener that don't exist/not accessible.
My guess is that you trying the wrong port "5121". Oracle default port is 1521.
Can you try with that and see what happens?
From the FAQ there are basically two ways of composing your JDBC string URL:
Old syntax
jdbc:oracle:thin:#[HOST][:PORT]:SID
New syntax
jdbc:oracle:thin:#//[HOST][:PORT]/SERVICE
My guess is that you are using the wrong syntax-SID/Service name combination, in other words, you are using the new syntax that requires the SERVICE name, but you are using the SID name to do it.
Try this: jdbc:oracle:thin:#earth-db-11:1521:stardev
Or maybe find out the Service name and apply it to the new syntax that you are using, instead of the SID name.
I have used Cassandra CQL driver to implement some module. I know CQL driver works on port 9042.My module is working fine on port 9042 for cassandra servers(tried both local and remote). However due to some constraints on the data center port 9042 is not open for Cassandra. I need to make my application work on this data center.
Can we use the same code in some way with port 9160? I know 9160 is the thrift port and used for many other drivers for Cassandra. I was just wondering if there is any hack possible to make CQL driver work on 9160 or modify the code as little as possible to make it work on 9160.
Currently when I try to use the same code with port 9160 it gives the following error
com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: xx.yy.zz.aa (com.datastax.driver.core.ConnectionException: [xx.yy.zz.aa :9160] Unexpected error during transport initialization
(com.datastax.driver.core.ConnectionException: [xx.yy.zz.aa :9160] Operation timed out)), xx.yy.zz.aa :9160
When I try to telnet 9160 port
telnet xx.yy.zz.aa 9160
Trying xx.yy.zz.aa...
Connected to xx.yy.zz.aa.
Escape character is '^]'.
xyzaaaa
Connection closed by foreign host.
Looking for some help.
You can make the CQL interface available on port 9160 by changing the native_transport_port from 9042 to 9160 in cassandra.yaml on your cassandra server(s). You will also need to change rpc_port to something other than 9160.
In the datastax java-driver you can configure the port to use in Cluster.Builder by using the withPort method.