
|
Doing a SQLDriverConnect fails in Apache with Error 500: "Internal Server Error"
Hi everyone!
I'm trying to create a .cgi that makes a connection to Oracle Database
using unixODBC (in a Red Hat Enterprise Linux 4 machine).
I've successfully compiled Apache (APR 1.2.12, APR-Util 1.2.12, HTTPD
2.2.8), unixODBC (2.2.12) and PHP (5.2.6) but when I try to run the cgi
from the web browser I get "Internal Server Error". If I run the same
cgi from command line it works wih no errors.
Here is my actual configuration:
/usr/local/etc/odbc.ini:
[SXDB]
Application Attributes = T
Attributes = W
BatchAutocommitMode = IfAllSuccessful
CloseCursor = T
DisableDPM = F
DisableMTS = T
Driver = ORACLE_ODBC_Driver_Linux_ora10g
DSN = SXDB
EXECSchemaOpt =
EXECSyntax = T
Failover = T
FailoverDelay = 10
FailoverRetryCount = 10
FetchBufferSize = 64000
ForceWCHAR = F
Lobs = T
Longs = T
MetadataIdDefault = F
QueryTimeout = T
ResultSets = T
ServerName = SXDB
SQLGetData extensions = F
Translation DLL =
Translation Option = 0
UserID = scatex
/usr/local/etc/odbcinst.ini:
[ORACLE_ODBC_Driver_Linux_ora10g]
Description = Oracle 10g R2 ODBC Driver for Linux
Driver = /home/oracle/oraHome1/lib/libsqora.so.10.1
Driver64 =
Setup =
Setup64 =
UsageCount = 1
CPTimeout =
CPReuse =
[ODBC]
Trace = Yes
TraceFile = /tmp/sql.log
ForceTrace = Yes
Pooling = Yes
When I run iusql I get:
[oracle@pjs-linux php-5.2.6]$ iusql SXDB scatex Scatex
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select sysdate from dual;
+--------------------+
| SYSDATE |
+--------------------+
| 2008-06-03 11:26:26|
+--------------------+
SQLRowCount returns -1
1 rows fetched
SQL> quit
I don't know why Apache is giving me Error 500 but if I run the .cgi
from command line everything works fine.
My .cgi is just doing a simple select (using SQLDriverConnect) and then
it disconnects.
>From apache logs I can see:
[Tue Jun 03 11:21:20 2008] [error] [client 172.18.200.62] Debug:
connect_odbc.c [connect_odbc] - ODBC string
'DSN=SXDB;UID=scatex;PWD=Scatex;', referer:
http://172.18.200.153/cgi-bin/get_ret.cgi
[Tue Jun 03 11:21:20 2008] [error] [client 172.18.200.62] connection
string is: DSN=SXDB;UID=scatex;PWD=Scatex;, referer:
http://172.18.200.153/cgi-bin/get_ret.cgi
[Tue Jun 03 11:21:20 2008] [error] [client 172.18.200.62] Premature end
of script headers: lista_alarmes.cgi, referer:
http://172.18.200.153/cgi-bin/get_ret.cgi
I can only think that Apache doesn't know how to execute
SQLDriverConnect. But if this is true,how do I make it work?
Any help would be very appreciated. I have no more clues or ideas to
solve this right now...
Best regards,
Miguel Rentes
_______________________________________________
unixODBC-support mailing list
unixODBC-support@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
|

|
RE: Doing a SQLDriverConnect fails in Apache with Error 500: "Internal Server Error"
If it works from the command line and doesnt work from a
daemon it is often due to different environments.
I would guess
that you lack a library search path for loading Oracle libraries required by
/home/oracle/oraHome1/lib/libsqora.so.10.1
Stefan
Hi everyone!
I'm trying to create a .cgi that
makes a connection to Oracle Database using unixODBC (in a Red Hat Enterprise
Linux 4 machine).
I've successfully compiled Apache (APR 1.2.12,
APR-Util 1.2.12, HTTPD 2.2.8), unixODBC (2.2.12) and PHP (5.2.6) but when I
try to run the cgi from the web browser I get "Internal Server Error". If I
run the same cgi from command line it works wih no errors.
Here is my
actual
configuration:
/usr/local/etc/odbc.ini:
[SXDB] Application
Attributes =
T Attributes =
W BatchAutocommitMode =
IfAllSuccessful CloseCursor =
T DisableDPM =
F DisableMTS =
T Driver =
ORACLE_ODBC_Driver_Linux_ora10g DSN =
SXDB EXECSchemaOpt =
EXECSyntax =
T Failover =
T FailoverDelay =
10 FailoverRetryCount =
10 FetchBufferSize =
64000 ForceWCHAR =
F Lobs = T Longs
= T MetadataIdDefault
= F QueryTimeout =
T ResultSets =
T ServerName = SXDB SQLGetData
extensions = F Translation
DLL = Translation
Option = 0 UserID
=
scatex
/usr/local/etc/odbcinst.ini:
[ORACLE_ODBC_Driver_Linux_ora10g] Description
= Oracle 10g R2 ODBC Driver for
Linux Driver =
/home/oracle/oraHome1/lib/libsqora.so.10.1 Driver64
= Setup =
Setup64 =
UsageCount =
1 CPTimeout =
CPReuse =
[ODBC] Trace =
Yes TraceFile =
/tmp/sql.log ForceTrace =
Yes Pooling = Yes
When I run
iusql I get:
[oracle@pjs-linux php-5.2.6]$ iusql SXDB scatex
Scatex +---------------------------------------+ |
Connected!
| |
| |
sql-statement
| | help
[tablename]
| |
quit
| |
| +---------------------------------------+ SQL> select sysdate from
dual; +--------------------+ |
SYSDATE
| +--------------------+ | 2008-06-03
11:26:26| +--------------------+ SQLRowCount returns -1 1 rows
fetched SQL> quit
I don't know why Apache is giving me Error 500
but if I run the .cgi from command line everything works fine.
My .cgi
is just doing a simple select (using SQLDriverConnect) and then it
disconnects.
>From apache logs I can see:
[Tue Jun 03
11:21:20 2008] [error] [client 172.18.200.62] Debug: connect_odbc.c
[connect_odbc] - ODBC string 'DSN=SXDB;UID=scatex;PWD=Scatex;', referer: http://172.18.200.153/cgi-bin/get_ret.cgi [Tue
Jun 03 11:21:20 2008] [error] [client 172.18.200.62] connection string is:
DSN=SXDB;UID=scatex;PWD=Scatex;, referer: http://172.18.200.153/cgi-bin/get_ret.cgi [Tue
Jun 03 11:21:20 2008] [error] [client 172.18.200.62] Premature end of script
headers: lista_alarmes.cgi, referer: http://172.18.200.153/cgi-bin/get_ret.cgi
I
can only think that Apache doesn't know how to execute SQLDriverConnect. But
if this is true,how do I make it work?
Any help would be very
appreciated. I have no more clues or ideas to solve this right
now...
Best regards,
Miguel
Rentes
_______________________________________________
unixODBC-support mailing list
unixODBC-support@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
|

|
Re: Doing a SQLDriverConnect fails in Apache with Error 500: "Internal Server Error"
Hi Stefan,
I have a printenv.cgi that I used before to see the environment
variables I have when I make a request with the web browser. Here is
the output:
DOCUMENT_ROOT="/home/scatex/dsv/sxbin/weblists/htdocs"
GATEWAY_INTERFACE="CGI/1.1"
HTTP_ACCEPT="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
HTTP_ACCEPT_CHARSET="ISO-8859-1,utf-8;q=0.7,*;q=0.7"
HTTP_ACCEPT_ENCODING="gzip,deflate"
HTTP_ACCEPT_LANGUAGE="pt-pt,pt;q=0.8,en;q=0.5,en-us;q=0.3"
HTTP_CACHE_CONTROL="no-cache"
HTTP_CONNECTION="keep-alive"
HTTP_COOKIE="PHPSESSID=ca37dscif7aeffg42pfn9f45o3"
HTTP_HOST="172.18.200.153:8080"
HTTP_KEEP_ALIVE="300"
HTTP_PRAGMA="no-cache"
HTTP_USER_AGENT="Mozilla/5.0 (X11; U; Linux i686; pt-PT; rv:1.9b5) Gecko/2008050509 Firefox/3.0b5"
LD_LIBRARY_PATH="/home/oracle/apache/lib:/home/oracle/apache/lib:/home/oracle/oraHome1/lib:/usr/local/lib:/home/scatex/dsv/sxbin"
ODBCINI="/usr/local/etc/odbc.ini"
ODBCINSTINI="/usr/local/etc/odbcinst.ini"
PATH=".:/usr/java/j2sdk1.4.2_09/bin:/usr/sbin:/etc:/bin:/usr/bin:/usr/local/bin:/usr/local/lib:/usr/X11R6/bin:/home/scatex/dsv/sxbin:/home/scatex/dsv/sxbin/scripts:/home/scatex/dsv/sxbin/grafs:/home/scatex/dsv/scatex/synoptic:/home/scatex/dsv/scatex/libsyno:/usr/xrt/bin:/home/oracle/oraHome1/bin"
QUERY_STRING=""
REMOTE_ADDR="172.18.200.62"
REMOTE_PORT="43898"
REQUEST_METHOD="GET"
REQUEST_URI="/cgi-bin/printenv.cgi"
SCRIPT_FILENAME="/home/scatex/dsv/sxbin/weblists/cgi-bin/printenv.cgi"
SCRIPT_NAME="/cgi-bin/printenv.cgi"
SERVER_ADDR="172.18.200.153"
SERVER_ADMIN=you@...
SERVER_NAME="172.18.200.153"
SERVER_PORT="80"
SERVER_PROTOCOL="HTTP/1.1"
SERVER_SIGNATURE=""
SERVER_SOFTWARE="Apache/2.2.8 (Unix) PHP/5.2.6"
TZ="PORST-0PORDT-1,M3.5.0/01:00,M10.5.0/03:00"
XAPPLRESDIR="/home/scatex/dsv/sxcli/resources_UK"
As you can see from LD_LIBRARY_PATH I have all the search path I
need. I compiled the .cgi with "cc -o testeODBC.cgi testeODBC.c -lodbc"
(libodbc.so is in /usr/local/lib) and it works from the command line
environment.
I'm afraid it isn't a search path problem. I've also checked
/etc/ld.so.conf and it has /usr/local/lib (and also added
/home/oracle/oraHome1/lib and did a ldconfig) but restarting apache
didn't do the job.
Any more ideas on what can be the source of the problem?
Regards,
Miguel Rentes
Stefan Radman wrote:
If it works from the command
line and doesnt work from a daemon it is often due to different
environments.
I
would guess that you lack a library search path for loading Oracle
libraries required by /home/oracle/oraHome1/lib/libsqora.so.10.1
Stefan
Hi everyone!
I'm trying to create a .cgi that makes a connection to Oracle Database
using unixODBC (in a Red Hat Enterprise Linux 4 machine).
I've successfully compiled Apache (APR 1.2.12, APR-Util 1.2.12, HTTPD
2.2.8), unixODBC (2.2.12) and PHP (5.2.6) but when I try to run the cgi
from the web browser I get "Internal Server Error". If I run the same
cgi from command line it works wih no errors.
Here is my actual configuration:
/usr/local/etc/odbc.ini:
[SXDB]
Application Attributes = T
Attributes = W
BatchAutocommitMode = IfAllSuccessful
CloseCursor = T
DisableDPM = F
DisableMTS = T
Driver = ORACLE_ODBC_Driver_Linux_ora10g
DSN = SXDB
EXECSchemaOpt =
EXECSyntax = T
Failover = T
FailoverDelay = 10
FailoverRetryCount = 10
FetchBufferSize = 64000
ForceWCHAR = F
Lobs = T
Longs = T
MetadataIdDefault = F
QueryTimeout = T
ResultSets = T
ServerName = SXDB
SQLGetData extensions = F
Translation DLL =
Translation Option = 0
UserID = scatex
/usr/local/etc/odbcinst.ini:
[ORACLE_ODBC_Driver_Linux_ora10g]
Description = Oracle 10g R2 ODBC Driver for Linux
Driver = /home/oracle/oraHome1/lib/libsqora.so.10.1
Driver64 =
Setup =
Setup64 =
UsageCount = 1
CPTimeout =
CPReuse =
[ODBC]
Trace = Yes
TraceFile = /tmp/sql.log
ForceTrace = Yes
Pooling = Yes
When I run iusql I get:
[oracle@pjs-linux php-5.2.6]$ iusql SXDB scatex Scatex
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select sysdate from dual;
+--------------------+
| SYSDATE |
+--------------------+
| 2008-06-03 11:26:26|
+--------------------+
SQLRowCount returns -1
1 rows fetched
SQL> quit
I don't know why Apache is giving me Error 500 but if I run the .cgi
from command line everything works fine.
My .cgi is just doing a simple select (using SQLDriverConnect) and then
it disconnects.
>From apache logs I can see:
[Tue Jun 03 11:21:20 2008] [error] [client 172.18.200.62] Debug:
connect_odbc.c [connect_odbc] - ODBC string
'DSN=SXDB;UID=scatex;PWD=Scatex;', referer: http://172.18.200.153/cgi-bin/get_ret.cgi
[Tue Jun 03 11:21:20 2008] [error] [client 172.18.200.62] connection
string is: DSN=SXDB;UID=scatex;PWD=Scatex;, referer: http://172.18.200.153/cgi-bin/get_ret.cgi
[Tue Jun 03 11:21:20 2008] [error] [client 172.18.200.62] Premature end
of script headers: lista_alarmes.cgi, referer: http://172.18.200.153/cgi-bin/get_ret.cgi
I can only think that Apache doesn't know how to execute
SQLDriverConnect. But if this is true,how do I make it work?
Any help would be very appreciated. I have no more clues or ideas to
solve this right now...
Best regards,
Miguel Rentes
_______________________________________________
unixODBC-support mailing list
unixODBC-support@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
|

|
RE: Doing a SQLDriverConnect fails in Apache with Error 500: "Internal Server Error"
> Any more
ideas on what can be the source of the problem? sorry no. does not
seem to be a trivial problem.
possibly writing some debug code into your program and
turning on ODBC tracing might help determine what exactly is making your program
fail.
Stefan
Hi Stefan,
I have a printenv.cgi that I used
before to see the environment variables I have when I make a request with the
web browser. Here is the output:
DOCUMENT_ROOT="/home/scatex/dsv/sxbin/weblists/htdocs"
GATEWAY_INTERFACE="CGI/1.1"
HTTP_ACCEPT="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
HTTP_ACCEPT_CHARSET="ISO-8859-1,utf-8;q=0.7,*;q=0.7"
HTTP_ACCEPT_ENCODING="gzip,deflate"
HTTP_ACCEPT_LANGUAGE="pt-pt,pt;q=0.8,en;q=0.5,en-us;q=0.3"
HTTP_CACHE_CONTROL="no-cache"
HTTP_CONNECTION="keep-alive"
HTTP_COOKIE="PHPSESSID=ca37dscif7aeffg42pfn9f45o3"
HTTP_HOST="172.18.200.153:8080"
HTTP_KEEP_ALIVE="300"
HTTP_PRAGMA="no-cache"
HTTP_USER_AGENT="Mozilla/5.0 (X11; U; Linux i686; pt-PT; rv:1.9b5) Gecko/2008050509 Firefox/3.0b5"
LD_LIBRARY_PATH="/home/oracle/apache/lib:/home/oracle/apache/lib:/home/oracle/oraHome1/lib:/usr/local/lib:/home/scatex/dsv/sxbin"
ODBCINI="/usr/local/etc/odbc.ini"
ODBCINSTINI="/usr/local/etc/odbcinst.ini"
PATH=".:/usr/java/j2sdk1.4.2_09/bin:/usr/sbin:/etc:/bin:/usr/bin:/usr/local/bin:/usr/local/lib:/usr/X11R6/bin:/home/scatex/dsv/sxbin:/home/scatex/dsv/sxbin/scripts:/home/scatex/dsv/sxbin/grafs:/home/scatex/dsv/scatex/synoptic:/home/scatex/dsv/scatex/libsyno:/usr/xrt/bin:/home/oracle/oraHome1/bin"
QUERY_STRING=""
REMOTE_ADDR="172.18.200.62"
REMOTE_PORT="43898"
REQUEST_METHOD="GET"
REQUEST_URI="/cgi-bin/printenv.cgi"
SCRIPT_FILENAME="/home/scatex/dsv/sxbin/weblists/cgi-bin/printenv.cgi"
SCRIPT_NAME="/cgi-bin/printenv.cgi"
SERVER_ADDR="172.18.200.153"
SERVER_ADMIN=you@...
SERVER_NAME="172.18.200.153"
SERVER_PORT="80"
SERVER_PROTOCOL="HTTP/1.1"
SERVER_SIGNATURE=""
SERVER_SOFTWARE="Apache/2.2.8 (Unix) PHP/5.2.6"
TZ="PORST-0PORDT-1,M3.5.0/01:00,M10.5.0/03:00"
XAPPLRESDIR="/home/scatex/dsv/sxcli/resources_UK"
As you can see from LD_LIBRARY_PATH I have all the search path I
need. I compiled the .cgi with "cc -o testeODBC.cgi testeODBC.c -lodbc"
(libodbc.so is in /usr/local/lib) and it works from the command line
environment.
I'm afraid it isn't a search path problem. I've also
checked /etc/ld.so.conf and it has /usr/local/lib (and also added
/home/oracle/oraHome1/lib and did a ldconfig) but restarting apache didn't do
the job.
Any more ideas on what can be the source of the
problem?
Regards,
Miguel Rentes
Stefan Radman
wrote:
If it works from the command line and doesnt work from
a daemon it is often due to different environments.
I would guess
that you lack a library search path for loading Oracle libraries required by
/home/oracle/oraHome1/lib/libsqora.so.10.1
Stefan
Hi
everyone!
I'm trying to create a .cgi that makes a connection to
Oracle Database using unixODBC (in a Red Hat Enterprise Linux 4 machine).
I've successfully compiled Apache (APR 1.2.12, APR-Util 1.2.12,
HTTPD 2.2.8), unixODBC (2.2.12) and PHP (5.2.6) but when I try to run the
cgi from the web browser I get "Internal Server Error". If I run the same
cgi from command line it works wih no errors.
Here is my actual
configuration:
/usr/local/etc/odbc.ini:
[SXDB] Application
Attributes =
T Attributes =
W BatchAutocommitMode =
IfAllSuccessful CloseCursor =
T DisableDPM =
F DisableMTS =
T Driver =
ORACLE_ODBC_Driver_Linux_ora10g DSN
= SXDB EXECSchemaOpt
= EXECSyntax =
T Failover =
T FailoverDelay =
10 FailoverRetryCount =
10 FetchBufferSize =
64000 ForceWCHAR =
F Lobs =
T Longs =
T MetadataIdDefault =
F QueryTimeout =
T ResultSets =
T ServerName = SXDB SQLGetData
extensions = F Translation
DLL = Translation
Option =
0 UserID =
scatex
/usr/local/etc/odbcinst.ini:
[ORACLE_ODBC_Driver_Linux_ora10g] Description
= Oracle 10g R2 ODBC Driver for
Linux Driver =
/home/oracle/oraHome1/lib/libsqora.so.10.1 Driver64
= Setup =
Setup64 =
UsageCount =
1 CPTimeout =
CPReuse =
[ODBC] Trace =
Yes TraceFile =
/tmp/sql.log ForceTrace =
Yes Pooling = Yes
When I
run iusql I get:
[oracle@pjs-linux php-5.2.6]$ iusql SXDB scatex
Scatex +---------------------------------------+ |
Connected!
| |
| |
sql-statement
| | help
[tablename]
| |
quit
| |
| +---------------------------------------+ SQL> select sysdate
from dual; +--------------------+ |
SYSDATE
| +--------------------+ | 2008-06-03
11:26:26| +--------------------+ SQLRowCount returns -1 1 rows
fetched SQL> quit
I don't know why Apache is giving me Error
500 but if I run the .cgi from command line everything works fine.
My .cgi is just doing a simple select (using SQLDriverConnect) and
then it disconnects.
>From apache logs I can see:
[Tue
Jun 03 11:21:20 2008] [error] [client 172.18.200.62] Debug: connect_odbc.c
[connect_odbc] - ODBC string 'DSN=SXDB;UID=scatex;PWD=Scatex;', referer:
http://172.18.200.153/cgi-bin/get_ret.cgi [Tue
Jun 03 11:21:20 2008] [error] [client 172.18.200.62] connection string is:
DSN=SXDB;UID=scatex;PWD=Scatex;, referer: http://172.18.200.153/cgi-bin/get_ret.cgi [Tue
Jun 03 11:21:20 2008] [error] [client 172.18.200.62] Premature end of
script headers: lista_alarmes.cgi, referer: http://172.18.200.153/cgi-bin/get_ret.cgi
I
can only think that Apache doesn't know how to execute SQLDriverConnect.
But if this is true,how do I make it work?
Any help would be very
appreciated. I have no more clues or ideas to solve this right
now...
Best regards,
Miguel
Rentes
_______________________________________________
unixODBC-support mailing list
unixODBC-support@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
|

|
Re: Doing a SQLDriverConnect fails in Apache with Error 500: "Internal Server Error"
Hi Stefan,
I already turned on ODBC tracing and when I try to run the .cgi I have
an IM004 error:
[ODBC][21523][__handles.c][447]
Exit:[SQL_SUCCESS]
Environment = 0x83f6090
[ODBC][21523][SQLSetEnvAttr.c][182]
Entry:
Environment = 0x83f6090
Attribute = SQL_ATTR_ODBC_VERSION
Value = 0x3
StrLen = 0
[ODBC][21523][SQLSetEnvAttr.c][349]
Exit:[SQL_SUCCESS]
[ODBC][21523][SQLAllocHandle.c][358]
Entry:
Handle Type = 2
Input Handle = 0x83f6090
[ODBC][21523][SQLAllocHandle.c][476]
Exit:[SQL_SUCCESS]
Output Handle = 0x83f6810
[ODBC][21523][SQLDriverConnect.c][678]
Entry:
Connection = 0x83f6810
Window Hdl = (nil)
Str In = [DSN=SXDB;PWD=******;][length = 20
(SQL_NTS)]
Str Out = 0xbfeb1af0
Str Out Max = 2048
Str Out Ptr = (nil)
Completion = 0
UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'
[ODBC][21523][SQLConnect.c][1315]Error: IM004
[ODBC][21523][SQLAllocHandle.c][523]
Entry:
Handle Type = 3
Input Handle = 0x83f6810
[ODBC][21523][SQLAllocHandle.c][549]Error: 08003
[ODBC][21523][SQLTables.c][175]Error: SQL_INVALID_HANDLE
[ODBC][21523][SQLNumResultCols.c][130]Error: SQL_INVALID_HANDLE
[ODBC][21523][SQLFetch.c][141]Error: SQL_INVALID_HANDLE
[ODBC][21523][SQLFreeHandle.c][352]Error: SQL_INVALID_HANDLE
[ODBC][21523][SQLFreeHandle.c][273]
Entry:
Handle Type = 2
Input Handle = 0x83f6810
[ODBC][21523][SQLFreeHandle.c][324]
Exit:[SQL_SUCCESS]
[ODBC][21523][SQLFreeHandle.c][206]
Entry:
Handle Type = 1
Input Handle = 0x83f6090
I don't know much about ODBC but this error is telling me that ODBC
can't allocate a SQL_HANDLE_HENV
handle? If so, what do I have t do to eliminate this error?
This is my simple .cgi code:
#include <stdio.h>
#include <sql.h>
#include <sqlext.h>
void extract_error(
char *fn,
SQLHANDLE handle,
SQLSMALLINT type);
void extract_error(
char *fn,
SQLHANDLE handle,
SQLSMALLINT type)
{
SQLINTEGER i = 0;
SQLINTEGER native;
SQLCHAR state[ 7 ];
SQLCHAR text[256];
SQLSMALLINT len;
SQLRETURN ret;
memset(text,0,256);
fprintf(stderr,
"\n"
"The driver reported the following diagnostics whilst
running "
"%s\n\n",
fn);
do
{
ret = SQLGetDiagRec(type, handle, ++i, state, &native,
text, sizeof(text), &len );
if (!SQL_SUCCEEDED(ret))
printf("%s:%ld:%ld:%s\n", state, i, native, text);
}
while( ret == SQL_SUCCESS );
}
main() {
SQLHENV env;
SQLHDBC dbc;
SQLHSTMT stmt;
SQLRETURN ret; /* ODBC API return status */
SQLSMALLINT columns; /* number of columns in result-set */
int row = 0;
//MLR - cgi stuff
printf("Content-Type: text/html\n\n");
printf("<html>\n");
printf("<head>");
printf("<link rel=\"stylesheet\" href=\"../styles.css\"
type=\"text/css\">");
/* Allocate an environment handle */
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
/* We want ODBC 3 support */
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
/* Allocate a connection handle */
SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
/* Connect to the DSN mydsn */
/* You will need to change mydsn to one you have created and tested */
SQLDriverConnect(dbc, NULL, "DSN=SXDB;PWD=Scatex;", SQL_NTS, NULL, 0,
NULL, SQL_DRIVER_NOPROMPT);
/* Allocate a statement handle */
SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
/* Retrieve a list of tables */
SQLTables(stmt, NULL, 0, "SCATEX", SQL_NTS, "MEDIDAS", SQL_NTS, NULL,
0);
/* How many columns are there */
SQLNumResultCols(stmt, &columns);
/* Loop through the rows in the result-set */
while (SQL_SUCCEEDED(ret = SQLFetch(stmt))) {
SQLUSMALLINT i;
printf("Row %d\n", row++);
/* Loop through the columns */
for (i = 1; i <= columns; i++) {
SQLINTEGER indicator;
char buf[512];
/* retrieve column data as a string */
ret = SQLGetData(stmt, i, SQL_C_CHAR, buf, sizeof(buf),
&indicator);
if (SQL_SUCCEEDED(ret)) {
/* Handle null columns */
if (indicator == SQL_NULL_DATA) strcpy(buf, "NULL");
printf(" Column %u : %s\n", i, buf);
} else {
extract_error("SQLAllocHandle for dbc", env, SQL_HANDLE_ENV);
exit(-1);
}
}
}
/* Free all the handles */
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
/* disconnect */
SQLFreeHandle(SQL_HANDLE_DBC, dbc);
SQLFreeHandle(SQL_HANDLE_ENV, env);
printf("</head>");
printf("<body bgcolor=\"#CCCCCC\" align=\"center\"
class=\"fText\">\n");
printf("</body>\n</html>\n");
}
Thanks in advance!
Miguel Rentes
Stefan Radman escreveu:
> Any more ideas on what can be the source
of the problem?
sorry no. does not seem to be a trivial problem.
possibly writing some debug code
into your program and turning on ODBC tracing might help determine what
exactly is making your program fail.
Stefan
Hi Stefan,
I have a printenv.cgi that I used before to see the environment
variables I have when I make a request with the web browser. Here is
the output:
DOCUMENT_ROOT="/home/scatex/dsv/sxbin/weblists/htdocs"
GATEWAY_INTERFACE="CGI/1.1"
HTTP_ACCEPT="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
HTTP_ACCEPT_CHARSET="ISO-8859-1,utf-8;q=0.7,*;q=0.7"
HTTP_ACCEPT_ENCODING="gzip,deflate"
HTTP_ACCEPT_LANGUAGE="pt-pt,pt;q=0.8,en;q=0.5,en-us;q=0.3"
HTTP_CACHE_CONTROL="no-cache"
HTTP_CONNECTION="keep-alive"
HTTP_COOKIE="PHPSESSID=ca37dscif7aeffg42pfn9f45o3"
HTTP_HOST="172.18.200.153:8080"
HTTP_KEEP_ALIVE="300"
HTTP_PRAGMA="no-cache"
HTTP_USER_AGENT="Mozilla/5.0 (X11; U; Linux i686; pt-PT; rv:1.9b5) Gecko/2008050509 Firefox/3.0b5"
LD_LIBRARY_PATH="/home/oracle/apache/lib:/home/oracle/apache/lib:/home/oracle/oraHome1/lib:/usr/local/lib:/home/scatex/dsv/sxbin"
ODBCINI="/usr/local/etc/odbc.ini"
ODBCINSTINI="/usr/local/etc/odbcinst.ini"
PATH=".:/usr/java/j2sdk1.4.2_09/bin:/usr/sbin:/etc:/bin:/usr/bin:/usr/local/bin:/usr/local/lib:/usr/X11R6/bin:/home/scatex/dsv/sxbin:/home/scatex/dsv/sxbin/scripts:/home/scatex/dsv/sxbin/grafs:/home/scatex/dsv/scatex/synoptic:/home/scatex/dsv/scatex/libsyno:/usr/xrt/bin:/home/oracle/oraHome1/bin"
QUERY_STRING=""
REMOTE_ADDR="172.18.200.62"
REMOTE_PORT="43898"
REQUEST_METHOD="GET"
REQUEST_URI="/cgi-bin/printenv.cgi"
SCRIPT_FILENAME="/home/scatex/dsv/sxbin/weblists/cgi-bin/printenv.cgi"
SCRIPT_NAME="/cgi-bin/printenv.cgi"
SERVER_ADDR="172.18.200.153"
SERVER_ADMIN=you@...
SERVER_NAME="172.18.200.153"
SERVER_PORT="80"
SERVER_PROTOCOL="HTTP/1.1"
SERVER_SIGNATURE=""
SERVER_SOFTWARE="Apache/2.2.8 (Unix) PHP/5.2.6"
TZ="PORST-0PORDT-1,M3.5.0/01:00,M10.5.0/03:00"
XAPPLRESDIR="/home/scatex/dsv/sxcli/resources_UK"
As you can see from LD_LIBRARY_PATH I have all the search
path I need. I compiled the .cgi with "cc -o testeODBC.cgi testeODBC.c
-lodbc" (libodbc.so is in /usr/local/lib) and it works from the command
line environment.
I'm afraid it isn't a search path problem. I've also checked
/etc/ld.so.conf and it has /usr/local/lib (and also added
/home/oracle/oraHome1/lib and did a ldconfig) but restarting apache
didn't do the job.
Any more ideas on what can be the source of the problem?
Regards,
Miguel Rentes
Stefan Radman wrote:
If it works from the command
line and doesnt work from a daemon it is often due to different
environments.
I
would guess that you lack a library search path for loading Oracle
libraries required by /home/oracle/oraHome1/lib/libsqora.so.10.1
Stefan
Hi everyone!
I'm trying to create a .cgi that makes a connection to Oracle Database
using unixODBC (in a Red Hat Enterprise Linux 4 machine).
I've successfully compiled Apache (APR 1.2.12, APR-Util 1.2.12, HTTPD
2.2.8), unixODBC (2.2.12) and PHP (5.2.6) but when I try to run the cgi
from the web browser I get "Internal Server Error". If I run the same
cgi from command line it works wih no errors.
Here is my actual configuration:
/usr/local/etc/odbc.ini:
[SXDB]
Application Attributes = T
Attributes = W
BatchAutocommitMode = IfAllSuccessful
CloseCursor = T
DisableDPM = F
DisableMTS = T
Driver = ORACLE_ODBC_Driver_Linux_ora10g
DSN = SXDB
EXECSchemaOpt =
EXECSyntax = T
Failover = T
FailoverDelay = 10
FailoverRetryCount = 10
FetchBufferSize = 64000
ForceWCHAR = F
Lobs = T
Longs = T
MetadataIdDefault = F
QueryTimeout = T
ResultSets = T
ServerName = SXDB
SQLGetData extensions = F
Translation DLL =
Translation Option = 0
UserID = scatex
/usr/local/etc/odbcinst.ini:
[ORACLE_ODBC_Driver_Linux_ora10g]
Description = Oracle 10g R2 ODBC Driver for Linux
Driver = /home/oracle/oraHome1/lib/libsqora.so.10.1
Driver64 =
Setup =
Setup64 =
UsageCount = 1
CPTimeout =
CPReuse =
[ODBC]
Trace = Yes
TraceFile = /tmp/sql.log
ForceTrace = Yes
Pooling = Yes
When I run iusql I get:
[oracle@pjs-linux php-5.2.6]$ iusql SXDB scatex Scatex
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select sysdate from dual;
+--------------------+
| SYSDATE |
+--------------------+
| 2008-06-03 11:26:26|
+--------------------+
SQLRowCount returns -1
1 rows fetched
SQL> quit
I don't know why Apache is giving me Error 500 but if I run the .cgi
from command line everything works fine.
My .cgi is just doing a simple select (using SQLDriverConnect) and then
it disconnects.
>From apache logs I can see:
[Tue Jun 03 11:21:20 2008] [error] [client 172.18.200.62] Debug:
connect_odbc.c [connect_odbc] - ODBC string
'DSN=SXDB;UID=scatex;PWD=Scatex;', referer: http://172.18.200.153/cgi-bin/get_ret.cgi
[Tue Jun 03 11:21:20 2008] [error] [client 172.18.200.62] connection
string is: DSN=SXDB;UID=scatex;PWD=Scatex;, referer: http://172.18.200.153/cgi-bin/get_ret.cgi
[Tue Jun 03 11:21:20 2008] [error] [client 172.18.200.62] Premature end
of script headers: lista_alarmes.cgi, referer: http://172.18.200.153/cgi-bin/get_ret.cgi
I can only think that Apache doesn't know how to execute
SQLDriverConnect. But if this is true,how do I make it work?
Any help would be very appreciated. I have no more clues or ideas to
solve this right now...
Best regards,
Miguel Rentes
_______________________________________________
unixODBC-support mailing list
unixODBC-support@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
|

|
Re: Doing a SQLDriverConnect fails in Apache with Error 500: "Internal Server Error"
Miguel Rentes wrote:
> Hi everyone!
>
> I'm feeling quite desperate... can anyone help me find out what is
> going on with SQLDriverConnect? I have manage to solve the problem I
> had the other day (see bellow) by changing httpd.conf and adding a
> "PassEnv ORACLE_HOME" directive, but now I have a similar problem in
> another .cgi, and I don't know what to do. I'm again getting the
> "IM004" error, which I can't seem to get what I have to do to correct
> it. This is code that is failing:
I would guess its the same sort of problem, the driver is failing for
whatever reason when its SQLAllocEnv is called. If the below code runs
outside Apache, then the difference between the two environments must be
the problem.
--
Nick Gorham
Easysoft Limited
http://www.easysoft.com, http://www.unixODBC.org_______________________________________________
unixODBC-support mailing list
unixODBC-support@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
|

|
Re: Doing a SQLDriverConnect fails in Apache with Error 500: "Internal Server Error"
Hi Nick,
I've done a simple .cgi that runs inside Apache and it works. But this
.cgi I'm working on right now is failing and I can't find the source of
the problem (since it follows the same steps as documented and as the
previous .cgi that worked) or how to correct it. If anyone has a clue
or a working example in Linux, please let me know.
Thanks in advance,
Miguel Rentes
Nick Gorham wrote:
Miguel
Rentes wrote:
Hi everyone!
I'm feeling quite desperate... can anyone help me find out what is
going on with SQLDriverConnect? I have manage to solve the problem I
had the other day (see bellow) by changing httpd.conf and adding a
"PassEnv ORACLE_HOME" directive, but now I have a similar problem in
another .cgi, and I don't know what to do. I'm again getting the
"IM004" error, which I can't seem to get what I have to do to correct
it. This is code that is failing:
I would guess its the same sort of problem, the driver is failing for
whatever reason when its SQLAllocEnv is called. If the below code runs
outside Apache, then the difference between the two environments must
be the problem.
_______________________________________________
unixODBC-support mailing list
unixODBC-support@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
|

|
Re: Doing a SQLDriverConnect fails in Apache with Error 500: "Internal Server Error"
Hi Nick,
If I run the .cgi from the command line I get the following output:
Content-Type: text/html
<html>
<head><link rel="stylesheet" href="../styles.css"
type="text/css"><META HTTP-EQUIV="refresh"
CONTENT="0;URL=../Notas_Entidades/print_not_ent.php"></head><body
bgcolor="#CCCCCC" align="center" class="fText">
Debug: connect_odbc.c [connect_odbc] - ODBC string
'DSN=SXDB;UID=scatex;PWD=Scatex;'
SQL_HANDLE_ENV well allocated!!
SQL_HANDLE_DBC well allocated!!
SQLDriverConnect well done!!
<br>SELECT DATA_, NOTE_TAG, DP_TAG, DP_TYP, FLAG, NOTE_TYP,
OPERATOR, note_file, flag FROM NOTETAG_OPERATION WHERE flag <>
'D' AND dp_typ ='' AND OPERATOR ='' ORDER BY DATA_
<br></body>
</html>
But when I run it from the web browser I get the "IM004" error. If
there's a problem with the Apache environment, how can I find the
cause? I have a .cgi that prints the environment variables under the
Apache environment but I don't see any that could be missing. Besides
the environment variables what can also be wrong with the Apache
environment? I also thought about permissions but I can execute .cgi
from the web browser, so I eliminated this possibility...
Thanks in advance,
Miguel Rentes
Nick Gorham wrote:
Miguel
Rentes wrote:
Hi Nick,
I've done a simple .cgi that runs inside Apache and it works. But this
.cgi I'm working on right now is failing and I can't find the source of
the problem (since it follows the same steps as documented and as the
previous .cgi that worked) or how to correct it. If anyone has a clue
or a working example in Linux, please let me know.
Thanks in advance,
Miguel Rentes
Nick Gorham wrote:
Miguel Rentes wrote:
Hi everyone!
I'm feeling quite desperate... can anyone help me find out what is
going on with SQLDriverConnect? I have manage to solve the problem I
had the other day (see bellow) by changing httpd.conf and adding a
"PassEnv ORACLE_HOME" directive, but now I have a similar problem in
another .cgi, and I don't know what to do. I'm again getting the
"IM004" error, which I can't seem to get what I have to do to correct
it. This is code that is failing:
I would guess its the same sort of problem, the driver is failing for
whatever reason when its SQLAllocEnv is called. If the below code runs
outside Apache, then the difference between the two environments must
be the problem.
But does the code you have there run if its run as a stand alone
application?
_______________________________________________
unixODBC-support mailing list
unixODBC-support@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
|

|
Re: Doing a SQLDriverConnect fails in Apache with Error 500: "Internal Server Error"
Miguel Rentes wrote:
> Hi Nick,
>
> If I run the .cgi from the command line I get the following output:
>
> Content-Type: text/html
>
> <html>
> <head><link rel="stylesheet" href="../styles.css"
> type="text/css"><META HTTP-EQUIV="refresh"
> CONTENT="0;URL=../Notas_Entidades/print_not_ent.php"></head><body
> bgcolor="#CCCCCC" align="center" class="fText">
> Debug: connect_odbc.c [connect_odbc] - ODBC string
> 'DSN=SXDB;UID=scatex;PWD=Scatex;'
> SQL_HANDLE_ENV well allocated!!
> SQL_HANDLE_DBC well allocated!!
> SQLDriverConnect well done!!
>
> <br>SELECT DATA_, NOTE_TAG, DP_TAG, DP_TYP, FLAG, NOTE_TYP, OPERATOR,
> note_file, flag FROM NOTETAG_OPERATION WHERE flag <> 'D' AND
> dp_typ ='' AND OPERATOR ='' ORDER BY DATA_
> <br></body>
> </html>
>
> But when I run it from the web browser I get the "IM004" error. If
> there's a problem with the Apache environment, how can I find the
> cause? I have a .cgi that prints the environment variables under the
> Apache environment but I don't see any that could be missing. Besides
> the environment variables what can also be wrong with the Apache
> environment? I also thought about permissions but I can execute .cgi
> from the web browser, so I eliminated this possibility...
Your library search path would be my bet, but other than that I don't know.
--
Nick Gorham
Easysoft Limited
http://www.easysoft.com, http://www.unixODBC.org_______________________________________________
unixODBC-support mailing list
unixODBC-support@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
|

|
Re: Doing a SQLDriverConnect fails in Apache with Error 500: "Internal Server Error"
by Miguel Rentes
::
Rate this Message:
|