Have anyone tried to use R and Oracle servers?
The credientials required for connection are:
HOST = somewhere.com
PORT = 1525
SERVICE_NAME = someservice
USERNAME = user
PASSWORD = pass
I've tried RODBC:
library(RODBC)
channel <- odbcConnect("somewhere.com:1525/someservice", uid="user", pwd="pass")
But it only gives me these warnings:
Warning messages:
1: In odbcDriverConnect("somewhere.com:1525/someservice", uid="user", pwd="pass") :
[RODBC] ERROR: state IM010, code 0, message [Microsoft][ODBC Driver Manager] Data source name too long
2: In odbcDriverConnect("somewhere.com:1525/someservice", uid="user", pwd="pass") :
ODBC connection failed
Are there other ways to connect to Oracle?
Thanks all
Related
I want to automate some SQL queries to save time, so I tried using SQL Alchemy to connect to the server.
conn = create_engine("mssql+pymssql:/<user>:<pass>#<address>/<database>")
query = pd.read_sql_query(<query>)
This gave me an unknown connection error, so I looked around and found pymssql
db= pymssql.connect(host=address, user=user, password=pass, database=db, port=1433)
I am now getting this error:
OperationalError: (20009), d'DB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (address:1433)\nNet-Lib error during Unknown error (10060)\n'
Any help would be appreciated.
I use the following specs to connect to db from Matlab and it works:
% Matlab code
spec.dbName = 'xxxyyy';
spec.login = 'uid';
spec.pwd = 'mypwd';
spec.driver = 'net.sourceforge.jtds.jdbc.Driver';
spec.url = 'jdbc:jtds:sqlserver://vmsqlprod7:1234/xxxyyy';
conn = database(spec.dbName, spec.login, spec.pwd, spec.driver, spec.url);
I'm almost sure this is all I need to connect from R. But I can't seem to make it work with the following code:
## R code
require(RODBC)
con <- odbcDriverConnect(connection=
"driver=net.sourceforge.jtds.jdbc.Driver;
server=jdbc:jtds:sqlserver://vmsqlprod7:1234/xxxyyy;
database=xxxyyy;
uid=uid;
pwd=mypwd")
It throws out this error:
[ODBC Driver Manager] Data source name not found and no default driver specified
I've read this and I suspect it's about the format of the url or driver string, but I don't know exactly how to make it recognizable by R.
I can really use some help here!
Environment: Windows 7, 64 bit.
R version: 3.3.3
I was trying to learn the new feature -- R in SQL Server 2016 and I was following this link as example.
I set up SQLRUserGroup as a new login and was able to run some R scripts, but the data_preprocess_score.sql gives me the following error message and it looked like related to connection.
Here is what I tried to call the sproc:
EXEC data_preprocess_score #testlength = 1, #id1value = 2, #id2value = 1,
#connectionString = 'SERVER=.;DATABASE=Test;Trusted_Connection=true;`'
Below is the error message:
Msg 39004, Level 16, State 20, Line 1
A 'R' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 1, Line 1
An external script error occurred:
[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.
Error in doTryCatch(return(expr), name, parentenv, handler) :
[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.
Calls: source ... tryCatch -> tryCatchList -> tryCatchOne -> doTryCatch -> .Call
In addition: Warning message:
In Ops.factor(tsvalues, value.threshold) : '>' not meaningful for factors
Error in ScaleR. Check the output for more information.
Error in eval(expr, envir, enclos) :
Error in ScaleR. Check the output for more information.
Calls: source -> withVisible -> eval -> eval -> .Call
Execution halted
STDOUT message(s) from external script:
Rows Read: 166, Total Rows Processed: 166Caught exception in file: CxAnalysis.cpp, line: 6488. ThreadID: 14112 Rethrowing.
[Microsoft][ODBC Driver Manager] Connection not open
ODBC Error in SQLDisconnect
Caught exception in file: CxAnalysis.cpp, line: 5682. ThreadID: 14112 Rethrowing.
Caught exception in file: CxAnalysis.cpp, line: 5249. ThreadID: 14112 Rethrowing.
Can someone help me with this error?
Thanks!
Add Driver=SQL Server to the front of your connection string. It wouldn't hurt to set Server=localhost too.
EXEC data_preprocess_score #testlength = 1, #id1value = 2, #id2value = 1,
#connectionString = 'Driver=SQL Server;SERVER=localhost;DATABASE=Test;Trusted_Connection=true;'
If you are able to run R scripts to get data, but get the following error with when writing data with rx functions like rxPredict/rxDataStep:
DBNETLIB; SQL Server does not exist or access denied
Then, you may be hitting an issue with loop back connections to SQL Server from R script. Please check the following configurations required for loop back connections:
Implied Authentication for Launchpad Accounts is enabled using instructions here
TCP/IP client protocol is enabled for the Server using instructions here
Specifically in your case, please check for the TCP/IP protocol configuration, since you mentioned the login for SQLRUserGroup was created.
import pyodbc
cnxn = pyodbc.connect('DRIVER={SQL Server Native Client 11.0};SERVER=LENOVO-PCN;DATABASE=testing;')
cursor = cnxn.cursor()
cursor.execute("select Sales from Store_Inf")
row = cursor.fetchone()
if row:
print (row)
I try using python 3 with module pyodbc to connect SQL Server Express.
My codes gave a error:
('08001', '[08001] [Microsoft][SQL Server Native Client 11.0]Named
Pipes Provider: Could not open a connection to SQL Server [2]. (2)
(SQLDriverConnect)')
Any idea for this?
Here is an example that worked for me using Trusted_Connection=yes
import pyodbc
conn_str = pyodbc.connect(
Trusted_Connection='Yes',
Driver='{ODBC Driver 11 for SQL Server}',
Server='SERVER_NAME,PORT_NUMBER',
Database='DATABASE_NAME'
)
connection = pyodbc.connect(conn_str)
Please note that port number is comma separated!
I have below code and I am getting error:
Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server in C:\xampp\htdocs\ldap.php on line 17
<?php
$ldapconfig['host'] = "dsua1.company.com";
$ldapconfig['port'] = 636;
$ldapconfig['basedn'] = "cn=userid,ou=Applications,ou=Company,ou=Services,dc=iM-2,dc=com";
$ldapconfig['binddn'] = "userid";
$ldapconfig['bindpw'] = "password";
$ldapconn=ldap_connect($ldapconfig['host'],$ldapconfig['port']);
ldap_bind($ldapconn, $ldapconfig['binddn'], $ldapconfig['bindpw']);
?>
Since you specified port 636, I assume that you need an SSL-connection to the server. This is achieved by:
ldap_connect("ldaps://".$ldapconfig['host']."/");
Otherwise it would try to send plaintext data which would not be accepted on an SSL-socket.
Furthermore, try this after ldap_connect() and before ldap_bind():
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
Sometimes an error occurs when an incorrect protocol version is used, 3 is common now, but not standard for the ldap_* PHP function family.