Sponsored Content
Full Discussion: Database connection
Top Forums Programming Database connection Post 13233 by whartoner on Monday 14th of January 2002 12:08:48 PM
Old 01-14-2002
Question Database connection

Hi!
I have very limited experience in UNIX, I have couple questions about database connection in C programs.
I used to use pro*C to setup database connection to a remote Oracle server when I was in school about 2 yrs ago, is this method still in use in commercial C programs nowdays? And how to make connection to remote Sybase or SQL server in C program on UNIX? Do those DB provide any lib to setup conection? Thanks guys!

Ed
 

10 More Discussions You Might Find Interesting

1. Programming

database connection

i want to connect c++ to ms access. i am not clear about the concept of odbc please make me clear that for the above connection which version of odbc i will need? i am working on solaris so is there any kind like an odbc for windows and odbc for solaris? form where i can get the odbc... (0 Replies)
Discussion started by: ramneek
0 Replies

2. UNIX for Dummies Questions & Answers

database connection failing from linux

Hi, I am trying to connect to an Oracle database using the following code : sqlplus username/password@database_name It was showing an error 'username/password invalid' But i tried: sqlplus username/password ,it was connecting now. Can anyone suggest what may be the... (1 Reply)
Discussion started by: DILEEP410
1 Replies

3. UNIX for Advanced & Expert Users

database connection (unresolved sqlcxt)

i have a little pro*c code (as shown below) to connect an oracle database. (in unix solaris platform) in the preprocessor compilation step everything is ok. but when i try to compile the code using cc i get the error below: ld: Unresolved: sqlcxt i think there is a problem while linking... (3 Replies)
Discussion started by: gfhgfnhhn
3 Replies

4. Shell Programming and Scripting

Connection to database through shell script

Hi when i am calling the shell script with two parameter like id and date it works fine.But the same shell script is call by java application it gives the error as shown below Thu Jan 8 04:13:22 EST 2009|The Get Segment Process Failed: SP2-0306: Invalid option. Usage: CONN where <logon>... (1 Reply)
Discussion started by: ravi214u
1 Replies

5. UNIX and Linux Applications

Connection time out from Database

Hi, Hi we have application running on Unix Server(solaris10), which establishes connection(sessions) with DATABASE(oracle 10g) which is on another server and firewal is there in between. After some time i am usually getting connection time out(oarcle error 3114/3113) in some of my... (0 Replies)
Discussion started by: ajaysahoo
0 Replies

6. Shell Programming and Scripting

Keep database connection opened!

Hello. I have to make a script with more than 1 SQL query and the problem is that i have to alternate from sql commands to unix commands. what i would like to know if it's posible(and how) to keep the databse connection opened till last sql command is ran and execute unix commands while the... (2 Replies)
Discussion started by: daniel1988
2 Replies

7. Shell Programming and Scripting

Database connection string

Hi, I am touching shell scripting after a long gap of 3 years and forgotten almost all of it. So need help from everyone to revamp myself. To begin,please tell me what does this part of script do ( I have been asked to go thru a script and get a feel of it): #get database connection... (1 Reply)
Discussion started by: agarwal
1 Replies

8. UNIX and Linux Applications

Identify server.database connection

Good afternoon i need your help, i am new at unix, in a ETL scenario like datastage is , there are a bunch of procesess (script shells) conecting to hetereogenius database source servers in order to extract information. Ive got 2 questions 1. Using unix how can i identify exactly the... (1 Reply)
Discussion started by: alexcol
1 Replies

9. Ubuntu

Database Connection

Hi, How to creating connection to mysql.I try to connect but the following error coming .How to solve it. Could not connect to New MySQL. Error creating SQL Model Connection connection to New MySQL. (Error: com.mysql.jdbc.Driver) com.mysql.jdbc.Driver Error creating JDBC Connection... (2 Replies)
Discussion started by: snallusami
2 Replies

10. Programming

System I database connection

Hi All. Does anybody here know the System I database? it's from IBM. because i don't know how to connect on the database using unix. How do i know what parameter will i use? Thanks, (2 Replies)
Discussion started by: znesotomayor
2 Replies
OCI_CLOSE(3)															      OCI_CLOSE(3)

oci_close - Closes an Oracle connection

SYNOPSIS
bool oci_close (resource $connection) DESCRIPTION
Unsets $connection. The underlying database connection is closed if no other resources are using it and if it was created with oci_con- nect(3) or oci_new_connect(3). It is recommended to close connections that are no longer needed because this makes database resources available for other users. PARAMETERS
o $connection - An Oracle connection identifier returned by oci_connect(3), oci_pconnect(3), or oci_new_connect(3). RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Closing a connection Resources associated with a connection should be closed to ensure the underlying database connection is properly terminated and the database resources are released. <?php $conn = oci_connect('hr', 'welcome', 'localhost/XE'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $stid = oci_parse($conn, 'SELECT * FROM departments'); $r = oci_execute($stid); oci_fetch_all($stid, $res); var_dump($res); // Free the statement identifier when closing the connection oci_free_statement($stid); oci_close($conn); ?> Example #2 Database connections are not closed until all references are closed The internal refcount of a connection identifier must be zero before the underlying connection to the database is closed. <?php $conn = oci_connect('hr', 'welcome', 'localhost/XE'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $stid = oci_parse($conn, 'SELECT * FROM departments'); // this increases the refcount on $conn oci_execute($stid); oci_fetch_all($stid, $res); var_dump($res); oci_close($conn); // $conn is no longer usable in the script but the underlying database // connection is still held open until $stid is freed. var_dump($conn); // prints NULL // While PHP sleeps, querying the Oracle V$SESSION view in a // terminal window will show that the database user is still connected. sleep(10); // When $stid is freed, the database connection is physically closed oci_free_statement($stid); // While PHP sleeps, querying the Oracle V$SESSION view in a // terminal window will show that the database user has disconnected. sleep(10); ?> Example #3 Closing a connection opened more than once When database credentials are reused, both connections must be closed before the underlying database connection is closed. <?php $conn1 = oci_connect('hr', 'welcome', 'localhost/XE'); // Using the same credentials reuses the same underlying database connection // Any uncommitted changes done on $conn1 will be visible in $conn2 $conn2 = oci_connect('hr', 'welcome', 'localhost/XE'); // While PHP sleeps, querying the Oracle V$SESSION view in a // terminal window will show that only one database user is connected. sleep(10); oci_close($conn1); // doesn't close the underlying database connection var_dump($conn1); // prints NULL because the variable $conn1 is no longer usable var_dump($conn2); // displays that $conn2 is still a valid connection resource ?> Example #4 Connections are closed when variables go out of scope When all variables referencing a connection go out of scope and are freed by PHP, a rollback occurs (if necessary) and the underly- ing connection to the database is closed. <?php function myfunc() { $conn = oci_connect('hr', 'hrpwd', 'localhost/XE'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $stid = oci_parse($conn, 'UPDATE mytab SET id = 100'); oci_execute($stid, OCI_NO_AUTO_COMMIT); return "Finished"; } $r = myfunc(); // At this point a rollback occurred and the underlying database connection was released. print $r; // displays the function return value "Finished" ?> NOTES
Note Variables that have a dependency on the connection identifier, such as statement identifiers returned by oci_parse(3), must also be freed before the underlying database connection is closed. Note Prior to version PHP 5.1.2 (PECL OCI8 1.1) oci_close(3) was a no-op. In more recent versions it correctly closes the Oracle connec- tion. Use oci8.old_oci_close_semantics option to restore old behavior of this function. Note The oci_close(3) function does not close the underlying database connections created with oci_pconnect(3). SEE ALSO
oci_connect(3), oci_free_statement(3). PHP Documentation Group OCI_CLOSE(3)
All times are GMT -4. The time now is 01:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy