I have a code that connect successful through a libname to a Hive2 DB authenticated with kerberos:
libname hdb hadoop server="server-name" port=10000 schema="schema-name";
I have tested the code using Data Integration Studio and BASE, but when I call the same code with and the same user (checked putting in the code a %put &=SYSUSERID; and running in pipe a echo %username%) with a stored procedure the libname gives me error :
ERROR: Error trying to establish connection: Could not open client transport with JDBC Uri:
jdbc:hive2://"server-name":10000/"schema-name";ssl=true;principal=hive/_HOST#"dominion": GSS initiate
failed
ERROR: Error in the LIBNAME statement.
How can I connect to a sql server using jdbc in spark-shell and then query the database using a stored procedure?
I have seen this code:
val url =
"jdbc:mysql://yourIP:yourPort/test?
user=yourUsername; password=yourPassword"
val df = sqlContext
.read
.format("jdbc")
.option("url", url)
.option("dbtable", "people")
.load()
But I need to run a stored procedure.
When I use exec command for the dbtable option above, it gives me this error:
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near
the keyword 'exec'.
I am trying to connect to a MySQL server through R and it works perfect with the follwoing line:
con <- dbConnect(MySQL(), user="user", password="password",dbname="dbname", host="localhost", port=3306)
But, I would like to use a cnf file so that my user/apssword credentials donot appear in my code and tried the following:
rmysql.settingsfile<-"mydefault.cnf"
rmysql.db<-"test_db"
drv<-dbDriver("MySQL")
con<-dbConnect(drv,default.file=rmysql.settingsfile,group=rmysql.db)
And this is how my cnf file looks:
[test_db]
user=user
password=password
database=dbname
host=localhost
port=3306
It is in the same folder as in my R script which is my current working directory. But, I run into the following error:
Error in mysqlNewConnection(drv, ...) :
RS-DBI driver: (Failed to connect to database: Error: Access denied for user 'ODBC'#'localhost' (using password: NO)
)
Any suggestions, please?
Thanks so much
I had this problem very recently. RMySQL looks in the root directory for these files so you need to fully qualify the location of the file. i.e.:
rmysql.settingsfile<-"/home/MD-Tech/mydefault.cnf"
or
rmysql.settingsfile<-"c:\Users\MD-Tech\rfiles\mydefault.cnf"
Two things could be going on.
The CNF file should be encrypted, password should say password = ****. The MySQL documentation shows how to create a CNF file. Below would work for your code to create the CNF
shell> mysql_config_editor set --login-path=test_db --host=localhost --user=user --password
press enter without typing password, you will be prompted to enter it
The second thing is that user = NULL and password = NULL are missing as referenced in the src_mysql documentation
rmysql.settingsfile <- "~/.mylogin.cnf"
rmysql.db <- "test_db"
drv <- dbDriver("MySQL")
con <- dbConnect(drv, default.file = rmysql.settingsfile, group = rmysql.db, user = NULL, password = NULL)
When you add these and run the code, you should be set.
Fing something working at: https://www.r-bloggers.com/mysql-and-r/
Not in configuration file... but work.
con <- dbConnect(MySQL(),
user="me", password="nuts2u",
dbname="my_db", host="localhost")
Ya, getting this setup for the first time can be like pulling cats' teeth! Here is what I did while running R on a Droplet (Ubuntu 16.04, MySQL 5.7.16).
First, make sure you can at least login successfully to MySQL through the terminal
mysql -u kevin -p
Next, run R and verify that you can login in directly with dbConnect() using a user name and password
mydb = dbConnect(drv, user='kevin', password='ilovecats', dbname='catnapdb', host='127.0.0.1', port=3306)
Edit your mysql.cnf text file and at the bottom add a new group (exact name of this file and its location will depend on operating system and versions).
[whiskerpatrol]
user = kevin
password = ilovecats
host = 127.0.0.1
port = 3306
database = catnapdb
I have written these codes. But they did not work well. It hase some errors like this:
Warning: mysqli_connect() [function.mysqli-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\wamp\www...
and sometime is shows T_EXIT error.
My problem is in "or die" command. Suppose it cannot connect to database. Then it should switch on "or die" & terminates the the program. But it didn't do that. How can I fix it?
$dbc = mysqli_connect('localhost', 'user', 'pass', 'table')
or die('Error connecting to MySQL server.');
My problem is in "or die" command. Suppose it cannot connect to database. Then it should switch on "or die" & terminates the the program.
Answer comes Straight from PHP Manual
$link = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db');
if (!$link) {
die('Connect Error (' . mysqli_connect_errno() . ') '.mysqli_connect_error());
}
I'm new to symfony. My existing application is developed in symfony1.4. They didn't used any db connection. Now I want to create new MySQL database connection in this application.
How can I do that?
in settings.yml
all:
use_database: true
from the console run this command
php symfony configure:database "mysql:host=dbhost;dbname=yourdbname" dbuser dbpassword
Please check all the steps to make db connection symfony1.4
Step 1 :
file : config/ProjectConfiguration.class.php
find what:
---------
public function setup()
{
$this->enablePlugins('owCorePlugin');
}
Repalce with :
------------
public function setup()
{
$this->enablePlugins('owCorePlugin');
$this->enablePlugins('sfDoctrinePlugin');
}
Step 2 :
config/databases.yml
You need to create this file and add below code.replace caps letter with your details.You need to maintain same space also.
all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: mysql:host=HOST_NAME;dbname=DB_NAME
username: USERNAME
password: PASSWORD
Step 3:
frontend/config/settings.yml
find what :
use_database: false
Replace with
use_database: true
Run the following command:
change the project configuration.Make sure you need to run this command in root folder of our project
php symfony configure:database --name=doctrine --class=sfDoctrineDatabase "mysql:host=HOST_NAME;dbname=DB_NAME" USERNAME PASSWORD
step 5: schema files
$ php symfony doctrine:build-schema
$ php symfony doctrine:build-model
$ php symfony doctrine:build-forms
$ php symfony doctrine:build-filters
$ ln -s lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/web web/sfDoctrinePlugin