Troubleshooting connection errors

Scott Klement's open source interface to using JDBC database drivers from RPG. http://www.scottklement.com/jdbc/
Post Reply
iDevDaly
Posts: 5
Joined: Fri Jan 21, 2022 5:23 pm

Troubleshooting connection errors

Post by iDevDaly »

I'm using JDBCR4 to attempt connection to a SQL Server database. I've written several other programs that connect to one MSSQL database. But this is a new database, and I'm having issues. The error that gets returned by jdbc_ConnProp() is "Login failed for user."

I have an SQL client running on my laptop where I can connect directly to the database and run statements against my tables. It's using the same connection credentials that my program is using. It works and my program doesn't. This makes me confident I'm using the correct user name and password. I must have some issues with one of the other connection properties. I just can't figure out which one.

When JNI_CHECKERROR runs it spits out the java exception list to the screen, but I can't see the top of the list, and I can't do anything with it. The screen holds for 10 seconds and the exception list is gone. How can I go back and view that JVM console log after my program shuts down? I think if I could get a look at the java exceptions that get through by my connection attempt, I might be ale to figure this thing out.
Scott Klement
Site Admin
Posts: 635
Joined: Sun Jul 04, 2021 5:12 am

Re: Troubleshooting connection errors

Post by Scott Klement »

I'm guessing that you are running this in a 5250 (green-screen) session. Is that correct?

If so, you can do something like this to direct the Java errors to a spooled file (This must be done before the JVM is started):

Code: Select all

OVRPRTF FILE(STDOUT) TOFILE(QSYSPRT) HOLD(*YES)
OVRPRTF FILE(STDERR) TOFILE(QSYSPRT) HOLD(*YES)
Then run the program and recreate the problem (Java errors will not print on the screen, they will go to the spool.)

Then sign off of the job with the JVM running -- this is needed to close the spooled file.

Now you can check the spool to see the errors.
Scott Klement
Site Admin
Posts: 635
Joined: Sun Jul 04, 2021 5:12 am

Re: Troubleshooting connection errors

Post by Scott Klement »

Not sure if this is helpful, but.. a common cause of problems like this...

SQL Server authentication mode can be set for "Windows Authentication". Windows Authentication will only work from Microsoft Windows, so won't work with a JDBC driver running on any other platform.

The alternative is "SQL Server Authentication" -- this allows applications on other platforms.

https://docs.microsoft.com/en-us/sql/re ... ation-mode
iDevDaly
Posts: 5
Joined: Fri Jan 21, 2022 5:23 pm

Re: Troubleshooting connection errors

Post by iDevDaly »

It turns out there were 2 issues:

1. they were using a different port than the standard, and
2. I was using an outdated JDBC driver

All is okay now.
Post Reply