473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Oracle Connectivity

cpiyush
31
Hi. I am using Cx_Oracle inteface for conectivity to Oracle db server.

This is my code.
connection = cx_Oracle.connect("sys/demo@Sample.Natas1 as sysdba")
cursor = connection.cursor()
cursor.arraysize = 50
cursor.execute("""select col1, col2 from tab1""")
for column_1, column_2 in cursor.fetchall():
print "Values:", column_1, column_2


& When i am running this I am getting this error: -
cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve service name

Can you please tell me what to with this??

Thanks & Regards,
Piyush.
Apr 17 '07 #1
7 7632
ghostdog74
511 Expert 256MB
verify your database or server name is correct and that it can be resolved by DNS. Also take a look at here
Apr 17 '07 #2
cpiyush
31
verify your database or server name is correct and that it can be resolved by DNS. Also take a look at here
I read this & the db name is correct.
can you tell me wher to check the server name?
Apr 17 '07 #3
ghostdog74
511 Expert 256MB
I read this & the db name is correct.
can you tell me wher to check the server name?
sorry, I don't really use oracle. But here's what you can do.
just remove the other lines, and only left this line:
Expand|Select|Wrap|Line Numbers
  1. connection = cx_Oracle.connect("sys/demo@Sample.Natas1 as sysdba")
  2.  
if you still get the error, its got something to do with the connection string.
OR, you can use the makedsn() method to create a connection string for your use. check the docs on how to use it. make sure Sample.Natas1 is in your TNS entry (from the Oracle names server or tnsnames.ora file).
Apr 17 '07 #4
cpiyush
31
sorry, I don't really use oracle. But here's what you can do.
just remove the other lines, and only left this line:
Expand|Select|Wrap|Line Numbers
  1. connection = cx_Oracle.connect("sys/demo@Sample.Natas1 as sysdba")
  2.  
if you still get the error, its got something to do with the connection string.
OR, you can use the makedsn() method to create a connection string for your use. check the docs on how to use it. make sure Sample.Natas1 is in your TNS entry (from the Oracle names server or tnsnames.ora file).
Hey Thanks man.
I have got solution... After some brain storming. Now I am using makedsn() function & its creating the connection without any error. The code is as follows: -

host = 'localhost'
port = 1521
dbase = 'Sample'
login = 'demo'
passwrd = 'demo'
dsn = cx_Oracle.makedsn(host, port, dbase)
connection = cx_Oracle.connect(login, passwrd, dsn)


But Now I have some other problem.
I have created this user 'demo' & granted all the privileges to it. But when I am logging thru this & accessing that table, then its saying ORA-00942: table or view does not exist.

You said You dont use Oracle, but can you suggest me soething on this??
Apr 18 '07 #5
ghostdog74
511 Expert 256MB
Hey Thanks man.
I have got solution... After some brain storming. Now I am using makedsn() function & its creating the connection without any error. The code is as follows: -

host = 'localhost'
port = 1521
dbase = 'Sample'
login = 'demo'
passwrd = 'demo'
dsn = cx_Oracle.makedsn(host, port, dbase)
connection = cx_Oracle.connect(login, passwrd, dsn)


But Now I have some other problem.
I have created this user 'demo' & granted all the privileges to it. But when I am logging thru this & accessing that table, then its saying ORA-00942: table or view does not exist.

You said You dont use Oracle, but can you suggest me soething on this??
from your error , you can easily guess that its a table/view problem. Is your table or view called tab1 (from previous post) created in "Sample" database?
Apr 18 '07 #6
cpiyush
31
from your error , you can easily guess that its a table/view problem. Is your table or view called tab1 (from previous post) created in "Sample" database?
Yes. This table 'tab1' is created in db named 'Sample'.
& I have given all the privileges to user 'demo' on this table.
But all these privileges are not getting refelected when I am logging thru 'demo' & trying to execute 'select' stament.

My basic problem is coming here that I am create a user---> granting all the privileges---> Logging in thru that user ---> Trying to execute those privileges (But those privileges are not getting refelected )
Apr 18 '07 #7
ghostdog74
511 Expert 256MB
Yes. This table 'tab1' is created in db named 'Sample'.
& I have given all the privileges to user 'demo' on this table.
But all these privileges are not getting refelected when I am logging thru 'demo' & trying to execute 'select' stament.

My basic problem is coming here that I am create a user---> granting all the privileges---> Logging in thru that user ---> Trying to execute those privileges (But those privileges are not getting refelected )
well, its beyond my means now. The last thing i suggest is to log in to Oracle using its client interface (SQL plus or something) and see if you really cannot select from tab1.
Apr 18 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Alex | last post by:
I have developed a VB application that uses Oracle 8i database for backend. The database server is on the local network. From my development machine, the application connects (via ODBC) to the...
2
by: Axel Dachtler | last post by:
I am looking for detailed information about the topic "connectivity" in Oracle 9i including JDBC and CGI. Thank you
1
by: Ton | last post by:
I have a question about connectivity between different databases. Oracle, DB2400 and SQL_server. It is easy to integrate application products that are running on different DB platforms? What...
2
by: New Devil | last post by:
can anyone send a code for the oracle connectivity wid C#.. would be really tahnkful .. Desert Desperado 8) Posted Via Usenet.com Premium Usenet Newsgroup Services...
1
by: lovkeshanand | last post by:
Dear All, I am using the oracle transparent gateway connectivity with sql server using tg4msql,as far as settings are concerned those were set and Connectivity is working Fine, and getting the...
7
by: D. Patrick | last post by:
I need to connect to an Oracle database. I've never done it before. I see that with framework 1.1 you had to download ODP.NET from Oracle's site in order for the framework classes to even work....
9
by: rahul | last post by:
Hello every1 Can any1 tell me that What are teh various methods by which we can connect our database in sql to our project's front end which is in VB ?? I wanna know the pros and cons of various...
2
by: ahogan | last post by:
Previously posted on comp.databases.oracle.misc. Apologies to those who read both groups. I have created a link using generic connectivity from an Oracle 10.2.0.1 instance running on windows...
5
by: Scav | last post by:
Helpful folks, I am having a problem getting Oracle's Transparent Gateway for DRDA product to interface with DB2 UDB for LUW 8.1.14. The Gateway product is running on Linux and using DRDA...
4
by: reachravi | last post by:
Hi, In our ASP application, we are using a visual basic Dll file to perform database operations. We have a function in our Dll file for executing stored procedures. This function...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.