Unable to connect MySQL using R - java

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")

Related

Can't connect to remote MySQL (MariaDB) database in .NET but I can with Java

I am trying to migrate some code from JavaFX to use C# for Windows Forms. In Java, I was using JDBC and could connect just fine programmatically. Nos that I am trying to use C# I am getting this error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server).
I am using the same server address and credentials. I'm using System.Data.SqlClient. I've tried a bunch of different combinations but can't get the connection string to work.
String connectionString = "server=[Server URL];database=[Database Name];persist security info=true;user id=[Username];pwd=[Password]";
Here is an example of the mysql connection string:
string connectionString = "datasource= <database ip or domain>; port=<port, usually 3306>;username=<database user>;password=<user's password>;SslMode=none<this is important if you don't use ssl>;database=<your database>";
I think the reason you can't connect is because you haven't specified the SslMode.

java.sql.SQLException: The application requester cannot establish the connection

I have written a java program to connect to AS400 DB. I am using jt400-6.4.jar to connect to DB.
DB Properties I am using:
as400_dbUrl=jdbc:as400://host/schema;translate binary=true
as400_dbUser=user
as400_dbPassword=pass
My program is not able to connect to DB server i am getting the below error.
2017-06-30 05:36:53 ERROR DBUtil:88 - Exception:
java.sql.SQLException: The application requester cannot establish the connection. (A remote host refused an attempted connect operation.)
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:528)
at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:3130)
at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1360)
at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:1211)
at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:352)
at java.sql.DriverManager.getConnection(DriverManager.java:426)
at java.sql.DriverManager.getConnection(DriverManager.java:474)
I googled about this, not able to find the exact reason.
I think jt400.jar will use 8471 as the port to connect to DB. Please correct me if I am wrong regarding this port.
I am not able to ping the host. ping host is not returning any response.
I am able to telnet like telnet host. But I am not able to telnet the system like telnet host 8471
Your hlep will be highly appreciable. Kindly help.
try updating your DB property as:
Add <:port-number> after host
as400_dbUrl=jdbc:as400://host:port/schema;translate binary=true
Hope this solves your problem.

Exception when connecting to Sybase using JDBC Driver

I'm new to Sybase database and trying to connect to Sybase using Java JDBC connection and sajdbc4.jar, but getting an error:
java.sql.SQLException: [Sybase][JDBC Driver][SQL Anywhere]Database server not found
Here is my connection string:
jdbc:sqlanywhere:uid=user;pwd=xxxx;eng=xx_sql;database=dummy;links=tcpip(host=xx.xx.xx.xx)
Firstly ensure that you point the database file to the SQL Anywhere Server and restart the server.
Secondly analyze your database logs, check if you can trace the connectivity with SQL PLUS or any other database connectivity tools.
If you are able to solve it, then that's fine or else I suspect that the issue to be related to this issue on SO here
As per this question, please make the following changes and I guess that the issue should be resolved
jdbc:sqlanywhere:Server=yourservername;uid=user;pwd=xxxx;port=2638;eng=xx_sql;database=dummy;links=tcpip(port=2638)
It is mandatory to mention the use of TCP/IP protocol to yourJDBC driver through the connection string above!
Hope this helps!

Error while trying to connect to database through eclipse database development perspective

This is error stack trace i am getting...
Could not connect to mydb.
Error creating SQL Model Connection connection to mydb. (Error: oracle.jdbc.OracleDriver)
oracle.jdbc.OracleDriver
Error creating JDBC Connection connection to mydb. (Error: oracle.jdbc.OracleDriver)
oracle.jdbc.OracleDriver.
I am using oracle thin driver to connect to database..
SID: db
Host: localhost
Port number 1521
User name: system
Password:
Connection URL: jdbc:oraclethin:©lccalhost:1521:db
I can't even able to ping the database...
There is a typo in your connection URL. It says lccalhost instead of localhost. Try:
jdbc:oraclethin:©localhost:1521:db
Furthermore, your log says mydb instead of db as stated in your connection settings. So, this may be another possible cause of fault.
I think you are using xpress edition 11-g and if so then try changing the SID from db to xe and then it should work fine .
If you are using the standard edition then you must check with the odbc jars .
Try adding odbc6 jar

Unable to connect to DB2 server via db2cmd

I'm unable to connect to db2 server using db2cmd command
db2 connect to mydb user myuser using password
Getting the following message
SQL8002N An attempt to connect to a host failed due to a missing DB2 Connect product or invalid license. SQLSTATE=42968
But I have successfully connected to this database using jdbc and I can view the structure.
Has anybody experienced such issue?
Are you trying to connect to a iSeries o z/390? or just a LUW (Linux, Unix Windows?)
If you are trying to connect to one of the two first, you need a DB2 Connect license, because they use the DRDA architecture, and it uses a special license.
Check the license
db2licm -a
If you are trying to connect to a LUW, you do not need any DB2 connect license, but probably there is a problem in you cataloged databases. Check the
db2 list node diretory
db2 list db directory
Is the database a remote server or is it a local connection?
Also, try to attach to the remote instance, in order to check that the node catalog is right
db2 attach to remoteInstance
As the error message says, you need DB2 Connect to serve as a gateway for CLI connections. The JDBC driver does not need the gateway, as it implements the required protocol.

Categories