This is a discussion on Re: how to connect to DB2-Server within the DB2 forums, part of the Database Server Software category; --> On Wed, 20 Aug 2003 13:51:35 +0200, Andreas Korthaus wrote: > Hi! > > The configuration of a client ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| On Wed, 20 Aug 2003 13:51:35 +0200, Andreas Korthaus wrote: > Hi! > > The configuration of a client to comunicate with a DB2 Server seems to be > very difficult. But I do not need to connect over the network, I would like > to use a simple Commandline-Client on the server-machine, where I can > connect by SSH. I do not want DB2-Server to listen to external connections, > I only need it on localhost. What I want to do is to use DB2-Server from > PHP. To set up PHP with DB2-support is no problem, but I do not know what I > have to do on DB2-Site. I used manual-unstall (db_install-Scrpt) and > configured DB 2 like this(in shell): > > /opt/IBM/db2/V8.1/instance/dascrt -u db2as > /opt/IBM/db2/V8.1/instance/db2icrt -a server -u db2fenc1 db2inst1 > /opt/IBM/db2/V8.1/cfg/db2ln > > What do I need now to connect from my PHP-application? I have to build a > databse and a user for PHP, how could I do this? Which admin-tool would you > recommend? I have no X installed(runlevel 3), and the server located in a > datacenter far away from here. > > Thank You! > > kind regards, > Andreas Korthaus > > PS: a license-question: do I need an own server-licence for each database or > only for each server-installation? Andreas, I assume you are able to start the DB2 instance you've created. If so then you need to add the db2profile script into your login script to set up the DB2 environment. Assuming the DB2 instance owner home directory is /home/db2inst1 then you'd add the following (for bash) - .. /home/db2inst1/sqllib/db2profile You will then be able to run commands like - db2 "connect to dbname" assuming you have authority to do so. To give a user SYSADM authority add him to the group db2iadm1. The licence is for servers, not for individual dbs. HTH Phil |
| |||
| Hi Philip, Philip Nelson wrote: > I assume you are able to start the DB2 instance you've created. I don't realy know. I did not start anything, but by using "db2"-commandline-tool I can create databases, insert sata, select data... But how sould I start? I tried db2 => connect to test Database Connection Information Database server = DB2/LINUX 8.1.0 SQL authorization ID = DB2INST1 Local database alias = TEST db2 => db2start SQL1026N The database manager is already active. db2 => db2stop SQL1025N The database manager was not stopped because databases are still active. db2 => I created the database "test", and I could do inserts and updates: db2 => select * from person NAME ------------------------------ testname 1 record(s) selected. But I did not anything else. I only used db2_install and the 3 shell-commands as mentioned before, to configure the server. I did not make anything with a client, I did not configure the comunication between server and client, and I did not use "Catalog" in the client. As it worked as above I thought it was not necessary. I use db2 Client and Server on the same machine, and all manuals I read described how to connect from a GUI-Client, that's not what I want. I Think I have to connect form the CLI-client to the server, and therefore I have to configure client _and_ server, right? But what should I configure and how? I have no access with any GUI-client, I would like to use the shell, because the server has no X installed (runlevel 3). I want to use DB2 for a PHP-Project, there I tried the following PHP-Code: <?php $dbname = "TEST"; $username = "db2inst1"; $password = "andreas"; // odbc_connect returns 0 if the connection attempt fails; // otherwise it returns a connection ID used by other ODBC functions $dbconn = odbc_connect($dbname, $username, $password); $sqlerror = odbc_errormsg($dbconn); echo($sqlerror); ?> If I run this script I get the Error: Warning: SQL error: [IBM][CLI Driver] SQLSTATE=58004, SQL state 58004 in SQLConnect in /home/www/easy-procure/live/http-root/admin/db2.php on line 9 (PHP es configured correct with DB2-Support) > . /home/db2inst1/sqllib/db2profile Yes, that made the Error-Message above visable, befor there was something like Warning: SQL error: |}!A, SQL state $E+F+?E+ýÿÿÿýÿÿÿýÿÿÿÈÈÿ¿Éÿ¿ in SQLConnect in /home/www/test/db2.php on line 9 > You will then be able to run commands like - > > db2 "connect to dbname" Yes, but this was also possible before > To give a user SYSADM authority add him to the group db2iadm1. So all "DB-Users" are also "System-Users"? I have no experience with a DB-Server as DB2 or Oracle, only with MySQL, PostgreSQL, and they are more simple. Perhaps someone has an idea what to do that I can connect from PHP, or how to set up the communication between Client und Server, if still necessary. Thank You very much for your help! Kind regards, Andreas |
| ||||
| Hi! > If I run this script I get the Error: > > Warning: SQL error: [IBM][CLI Driver] SQLSTATE=58004, SQL state 58004 > in SQLConnect in /home/www/easy-procure/live/http-root/admin/db2.php > on line 9 > > (PHP es configured correct with DB2-Support) > > >> . /home/db2inst1/sqllib/db2profile It was not enough to execute the Script from shell where I execute apachectl, I had to build this into apachectl script, now it works great! Thank You! Andreas |
| Thread Tools | |
| Display Modes | |
|
|