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.
Related
I am trying to connect to MongoDB Atlas DB from my spring boot app. I set the below listed properties in my application properties file. When I try to connect I see this exception "com.mongodb.MongoSocketException: No such host is known". However I am able to connect to this using mongodb compass from the same machine. Am I missing something?
spring.data.mongodb.authentication-database=
spring.data.mongodb.host=
spring.data.mongodb.port=
spring.data.mongodb.username=
spring.data.mongodb.password=
spring.data.mongodb.database=
I am also able to connect when I use the below -
spring.data.mongodb.uri=
Take a look at this: https://developer.mongodb.com/article/srv-connection-strings/
Atlas is giving you a connection string with the mongodb+srv syntax where the "host" part is actually a DNS SRV record that gives you a replica set, not a host. This is compatible with the spring.data.mongodb.uri parameter and of course with MongoDb compass.
However setting the spring.data.mongodb.host instead gives you the unknown host exception.
I don't know why this is happening error
I'm trying to simply connect my database to jdbc
In the url jdbc:mysel://localhost:test you set the host as localhost and the port as test
There is no such port called test, you need to provide a port number.
Most likely you are using the default port for mysql, so you might need to provide one at all.
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?
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. :(
When I print the I.P. address of the system using InetAddress.getLocalHost(), I get user-VAIO/192.168.1.3 . Now, when I connect to derby using jdbc:derby://localhost:1527/mydatabase;create=true, it connects without any errors but when I connect the same using jdbc:derby://192.168.1.3:1527/mydatabase;create=true, it fails giving me the following exception:-
java.net.ConnectException : Error connecting to server 192.168.1.3 on port 1527 with message Connection refused: connect.
Any help will be appreciated.
When you start your Derby Network Server, you provide a value for the '-h' argument. You might not realize you are doing this, if you are using the packaged StartNetworkServer.bat file, but look inside the batch file, and you will see the -h argument there.
The batch file comes provided with the syntax '-h default' when you download Derby from the Apache website.
But you can change that, to say, for example, '-h 192.168.1.3', and then your Derby Network Server will accept connections that specify 'jdbc:derby://192.168.1.3/my/database'.
Note that if you want to accept such connections from other computers on the network, you will also have to adjust your Windows Firewall rules, as by default it will prevent such connections.