Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • Last Modified:

Win32::ODBC connection in Tomcat/Perl

Hi,
   This is related to several other cases I've posted on EE about trying to run a Perl program in Apache Tomcat server that connects to a database. The essence of the problem is: I can run the Perl program just fine from command line, but when I try to run it in Tomcat, it just doesn't finish processing. Apparently, after inserting many debugging lines, the reason why it stalls is the following code:

$myDB = new Win32::ODBC($data_services) // this line runs fine if i execute Perl from command line, but stalls in Tomcat

is there any way to resolve this issue? Any help will be greatly appreciated. Thanks!
0
Envoy2064
Asked:
Envoy2064
  • 14
  • 13
  • 2
1 Solution
 
Envoy2064Author Commented:
Also, on the following page: http://tomcat.apache.org/faq/database.html

It says:

    *   Do not use JDBC-ODBC bridge bundled with Sun's JDK with Tomcat. It was never meant for a production server environment. If you ask a question about it, everyone will tell you to not use it. If you do need to use ODBC, there are 3rd party drivers which do a pretty good job at being thread safe.
    * If you use the oracle thin driver, be sure to rename it to a jar file from a zip file. Tomcat only auto-magically loads files ending in .jar placed in a lib directory. It ignores all other file extensions.

I'm not sure what this means for my problem here...
0
 
Envoy2064Author Commented:
Upped the point value. Any ideas? :-)
0
 
gheistCommented:
Does the data source work in plain java command line?
It is not thread safe just like many other type4 JDBC drivers.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Envoy2064Author Commented:
gheist, can you please explain more about thread safe for the JDBC drivers? Are you saying that the Tomcat/Java app server disables connections that are not thread safe?

Upped the point value again...

Thanks!
0
 
gheistCommented:
Any error that signifies connection disabled?
Post the code, please.
0
 
Envoy2064Author Commented:
No error at all, the Tomcat app just keeps running and hanging there...
0
 
gheistCommented:
WHERE IN THE CODE?
0
 
Envoy2064Author Commented:
At the following line:

$myDatabase = new Win32::ODBC($data_source);
0
 
gheistCommented:
Does it fail same way in plain java application?
0
 
gheistCommented:
Command line to stalled perl interpreter using "Process Explorer" from www.sysinternals.com.
Does it run same way outside tomcat?
0
 
Envoy2064Author Commented:
No, outside of Tomcat, the perl.exe process runs just fine and finishes in < 3 seconds.

Perl.exe is the process that's stalling while executing the perl script, as seen from the Task Manager...
0
 
gheistCommented:
Download "Process Explorer" program and examine perl command line and environment of stalled perl launched from Tomcat.
0
 
Envoy2064Author Commented:
I did what you suggested, and didn't see anything unusual in the Perl environment tab. However, in the Threads tab, I see something like "Wait:WrUserRequest"...seems to me it can't get into database?
0
 
gheistCommented:
Seems it tries to open input and read ?nothing?
0
 
Adam314Commented:
Are you using Sun's JDK?  From your first comment (after the original question), it sounds like this could be the problem.
0
 
gheistCommented:
Does the cgi run inside Apache webserver?
0
 
Envoy2064Author Commented:
Adam -- yes, I'm using the Sun's JDK to power the Tomcat server. Why would it be a problem?

gheist -- yes, the cgi runs in Apache webserver. I had some problems running CGI at first but after researching the web I found a way to make CGI run in Tomcat/Apache.

Changed point-value again. Thanks.
0
 
Adam314Commented:
I'm not sure why... but your first comment says you shouldn't use those in combination:
*   Do not use JDBC-ODBC bridge bundled with Sun's JDK with Tomcat. It was never meant for a production server environment. If you ask a question about it, everyone will tell you to not use it. If you do need to use ODBC, there are 3rd party drivers which do a pretty good job at being thread safe.

You might need either a different database driver or a different JDK.
0
 
gheistCommented:
Please mention version of perl interpreter, JDK and Tomcat server. I had enabled Activestate perl and it opens database connections from inside tomcat 5.5 just fine BEA Jrockit 6.0 win32
0
 
Envoy2064Author Commented:
Hi gheist, that would definitely help if you could tell me how you did it. :-)

java -version results in: 1.6.0_03

perl -v results in: 5.8.8

Tomcat: 5.5.25
0
 
Envoy2064Author Commented:
I was just thinking that it may be that the Perl script can't read the configuration file on the tomcat server that lets it get *into* the database....how can I be sure that it can access the configuration file w/ the username and password?
0
 
Envoy2064Author Commented:
Also, is it possible to create a Java program that calls the Perl script *from the command line*? So the Perl script would effectively be running in the command line, not in the cgi-bin of the Tomcat server...
0
 
gheistCommented:
%WINDIR%\SYSTEM32\CMD.EXE /C C:\PERL\BIN\PERL.EXE -W SCRIPT.PL
0
 
gheistCommented:
Sun/BEA/IBM JDK?
Cygwin perl or ActiveState or something else???
0
 
Envoy2064Author Commented:
using JNI?
0
 
gheistCommented:
Example:
1) java -version
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_13-b05, mixed mode)
2) perl -v
This is perl, v5.8.8 built for x86_64-linux-thread-multi
0
 
gheistCommented:
Using exec(), sir. Tomcat calls native CGI executable.
0
 
Envoy2064Author Commented:
Okay, I'm going to try your approach, gheist...but one more thing: how can I pipe the output back to the browser?
0
 
gheistCommented:
CGI of tomcat module gathers perl's output. I just wanted to stop JDBC discussions.
Writing own CGI module is not necessary.
Please tell which JDK you run, and whic perl you do use. It may be that another JDK and another perl interpreter will understand eachother just fine
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 14
  • 13
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now