aspose file tools*
The moose likes JDBC and the fly likes jdbc:odbc Bridge Failing Even With System ODBC variable set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc:odbc Bridge Failing Even With System ODBC variable set" Watch "jdbc:odbc Bridge Failing Even With System ODBC variable set" New topic
Author

jdbc:odbc Bridge Failing Even With System ODBC variable set

Al Johnston
Ranch Hand

Joined: May 02, 2009
Posts: 99

Hi everyone. I have a problem I can't figure out.

I wrote a Java object which feeds a DB and is called from ColdFusion. I uploaded my Java object and tested it on the server that it will run on (java - classpath ... Recievable). I created an ODBC source in Win 2008 for the DB at the system level. I ran the object and got my test data into the DB, no problem. So I call my ColdFusion programmer and tell him that it's good to go and write a little CF to show him how to instantiate the object.

He runs it and gets [Microsoft][ODBC Driver Manager] Invalid string or buffer length. You can try it yourself here: https://www.cpawins.com/_cpapubs/test1.cfm. I have the full stack trace being returned as a string in my catch clause so that it can be dumped by CF. The CF server sits on the same server that I tested my java code on and is calling the same DB (and again, I've set a Windows system level ODBC source). Why does it work when I run it through java at the command prompt but does not when I run it through CF?

The Connection is:



According to the StackTraceElements[] that you see on screen when you follow the link, the code is failing at line 55 which is the Connection invocation.

Your help is much appreciated.

Best,
Al
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2516
    
  10

What is the name of your datasource?


OCUP UML fundamental and ITIL foundation
youtube channel
Al Johnston
Ranch Hand

Joined: May 02, 2009
Posts: 99

Thanks Jan. And, I probably am just missing something somewhere. But, the confusion I have is this:

I ran this exact same code on the server using java -classpath and each time I do, I pass those values into the DB and get a successful return. When CF invokes the code, I get an error. How can this be? At first, I though that perhaps the CF code was sending in variables incorrectly which is why I output the variables I received in the <cfdump>. They are correct.

How can I have a query problem when everything is the same? It's not making sense to me.

Again:

java -classpath ...Recievable.getMoney(int,int,int) works fine

<cfobject component="...Recievable.getMoney(sameInt,sameInt,sameInt)> does not work fine

Al Johnston
Ranch Hand

Joined: May 02, 2009
Posts: 99

P_CPA
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2516
    
  10

I was just wondering if you have a user dztzsource with the same name as the system source.
In that case, maybe the code you run from the command prompt would use the user datasource, and the coldfusion code could pick up the system datasource ?


Al Johnston
Ranch Hand

Joined: May 02, 2009
Posts: 99

Hey, there's a plausible explanation! I'll check this out and follow up.

Thanks!
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2516
    
  10

Do you get the error in the line that creates the connection (as you say in your opening post) or in the method setMoney(int, int, int) (as shows on the exception page)?
Al Johnston
Ranch Hand

Joined: May 02, 2009
Posts: 99

I did check and there is no DMZ. The ODBC source I created should work for all connections to the DB. But, it does not.

Yet, the object fails at the connection point (line 55 which is Connection con = ...) and is in the method "setMoney(int,int,int). This has still left me baffled.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdbc:odbc Bridge Failing Even With System ODBC variable set