Trouble getting sqljdbc program running with new Java

I have a java program I've been running for a couple of years with java 7 and Microsoft sqljdbc 1.1 sqljdbc.jar on 32 bit Slackware 13.37. I done three things: 1) I've upgraded to 64bit Slackware 14.1; 2) I've upgraded to Java 8; 3) I am attempting to connect to the remote SQL Server from an Internet IP address, not from within the LAN.

This program is now having trouble connecting to the database.

I don't think it's the remote versus local IP. I can telnet to the SQL port just fine and get a prompt.

Below is a code fragment:
    try {
        Class.forName( dbDriver );

        con = DriverManager.getConnection( dbURL );
    }
    catch (SQLException e) {
        System.out.println("Sorry, unable to connect with Database Server. " +
            "Please try again later. Status: " + e.getErrorCode() + ", " +
            e.getMessage());
System.out.println("getClass() " + e.getClass());
System.out.println("getSQLState() " + e.getSQLState());
System.out.println("getNextException() " + e.getNextException());

      System.exit(e.getErrorCode());  timeout returns zero
    }
    catch (ClassNotFoundException x) {
        System.out.println("ClassNotFoundException: " + x);
    }
    catch (Exception q) { System.out.println("Exception: " + q); }

    try { stmt = con.createStatement(); }
    catch ( SQLException sqe) {
        System.out.println("Create Statement Failed: " + sqe.getErrorCode() + ": " + sqe.getMessage());
    }

Open in new window


When I run this the 1st exception triggers and I get:
Sorry, unable to connect with Database Server. Please try again later. Status: 0, mail: mail: unknown error
getClass() class com.microsoft.sqlserver.jdbc.SQLServerException
getSQLState() 08S01
getNextException() null

Open in new window

I looked up the 08S01 state and found "The communication link between the driver and the data source to which the driver was attempting to connect failed before the function completed processing. So usually its a network error. "

I'm at a loss as to where to look. I've tested with the firewall down on the SQL Server host. I have set the router to pass the SQL port to the correct host -- and I've tested the connection with telnet. my loginTimeout is set to 10 seconds, but it's coming back immediately.

Is it *really* a connectivity issue or is there some compatibility issue with sqljdbc and the newer java?

What else can I check?
LVL 1
MarkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Is the driver pure Java? I'm guessing the answer to that is yes, since you haven't mentioned any native binaries being involved.

If that's the case, another possible explanation is that there's a further layer of security at the db server level. Firewall says yes, but db says no.

I don't know MS Sql Server but that scenario could easily occur with, say, MySql. Sql Server people might know about the principle and how you can check it.

e.g the following shows allowing remote access, but check that the docs are also correct for your version:
http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx
0
MarkAuthor Commented:
CEHJ: > Is the driver pure Java?

I assume you're referring to the jdbc driver, right? This is a jarfile I downloaded long ago from Microsoft. I did not create the jarfile.

I've just tested with 2 different remote 32bit computers using the same java 7 runtime as is on the LAN client which has worked for a couple of years. Those tests worked! On of these machines has the same public IP and is on the same LAN as the problem 64bit computer.

So, it's not the network. It has something to do with Java 8, or the 32 versus 64 bit architecture and/or the Microsoft sqljdbc.jar 1.1.

Any insights?
0
MarkAuthor Commented:
More info: just tried it on a 3rd 32bit Linux with Java 7, also on the same LAN as the other working 32bit host  and the non-working 64bit host. This one also worked.

I think I'm doing the right things -- in any case I'm doing the usual things. Does 64bit need special consideration with jarfiles? with sqljdbc? Does Java 8 not work with something in my setup?
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

CEHJCommented:
I assume you're referring to the jdbc driver, right? This is a jarfile I downloaded long ago from Microsoft. I did not create the jarfile.
Yes - and no i don't expect you to be creating your own drivers.

 You could try http://www.microsoft.com/en-gb/download/details.aspx?id=11774

Out of interest - can you list the driver contents?

jar tf thedrivername.jar

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MarkAuthor Commented:
CEHJ: > Out of interest - can you list the driver contents?

Here you go. I suppose I could try downgrading back to Java 7, but I hate to do that. I'll check out your link.
$ jar tf /www/tomcat/lib/sqljdbc.jar
com/microsoft/sqlserver/jdbc/AppDTVImpl$SetValueOp.class
com/microsoft/sqlserver/jdbc/AppDTVImpl.class
com/microsoft/sqlserver/jdbc/AuthenticationJNI.class
com/microsoft/sqlserver/jdbc/CancelableRequest.class
com/microsoft/sqlserver/jdbc/CharacterStreamSetterArgs.class
com/microsoft/sqlserver/jdbc/ClientFetchBuffer.class
com/microsoft/sqlserver/jdbc/ClientSideCursor.class
com/microsoft/sqlserver/jdbc/Column.class
com/microsoft/sqlserver/jdbc/DataType.class
com/microsoft/sqlserver/jdbc/DataTypeFilteringDTVImpl.class
com/microsoft/sqlserver/jdbc/DataTypes.class
com/microsoft/sqlserver/jdbc/DBComms.class
com/microsoft/sqlserver/jdbc/DDC.class
com/microsoft/sqlserver/jdbc/DTV$SendByRPCOp.class
com/microsoft/sqlserver/jdbc/DTV.class
com/microsoft/sqlserver/jdbc/DTVExecuteOp.class
com/microsoft/sqlserver/jdbc/DTVImpl.class
com/microsoft/sqlserver/jdbc/ExecutableRequest.class
com/microsoft/sqlserver/jdbc/FailoverInfo.class
com/microsoft/sqlserver/jdbc/FailoverMapSingleton.class
com/microsoft/sqlserver/jdbc/FailoverServerPortPlaceHolder.class
com/microsoft/sqlserver/jdbc/FetchBuffer.class
com/microsoft/sqlserver/jdbc/ForwardOnlyDynamicServerCursor.class
com/microsoft/sqlserver/jdbc/InputStreamArgs.class
com/microsoft/sqlserver/jdbc/IOBuffer.class
com/microsoft/sqlserver/jdbc/JDBCCallSyntaxTranslator.class
com/microsoft/sqlserver/jdbc/KeysetServerCursor.class
com/microsoft/sqlserver/jdbc/PacketRequestor.class
com/microsoft/sqlserver/jdbc/Parameter$GetTypeDefinitionOp.class
com/microsoft/sqlserver/jdbc/Parameter.class
com/microsoft/sqlserver/jdbc/ParameterUtils.class
com/microsoft/sqlserver/jdbc/PLPInputStream.class
com/microsoft/sqlserver/jdbc/PLPXMLInputStream.class
com/microsoft/sqlserver/jdbc/PositionedCursor.class
com/microsoft/sqlserver/jdbc/ResultSetCursor.class
com/microsoft/sqlserver/jdbc/ScrollableDynamicServerCursor.class
com/microsoft/sqlserver/jdbc/ServerDTVImpl.class
com/microsoft/sqlserver/jdbc/ServerFetchBuffer.class
com/microsoft/sqlserver/jdbc/SLocaleMapItem.class
com/microsoft/sqlserver/jdbc/SQLCollation.class
com/microsoft/sqlserver/jdbc/SQLJdbcVersion.class
com/microsoft/sqlserver/jdbc/SQLServerBlob.class
com/microsoft/sqlserver/jdbc/SQLServerBlobInputStream.class
com/microsoft/sqlserver/jdbc/SQLServerBlobOutputStream.class
com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.class
com/microsoft/sqlserver/jdbc/SQLServerClob.class
com/microsoft/sqlserver/jdbc/SQLServerClobAsciiInputStream.class
com/microsoft/sqlserver/jdbc/SQLServerClobAsciiOutputStream.class
com/microsoft/sqlserver/jdbc/SQLServerClobCharacterReader.class
com/microsoft/sqlserver/jdbc/SQLServerClobWriter.class
com/microsoft/sqlserver/jdbc/SQLServerConnection$ConnectionCommandRequest.class
com/microsoft/sqlserver/jdbc/SQLServerConnection.class
com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.class
com/microsoft/sqlserver/jdbc/SQLServerConnectionSecurityManager.class
com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.class
com/microsoft/sqlserver/jdbc/SQLServerDataSource.class
com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.class
com/microsoft/sqlserver/jdbc/SQLServerDriver.class
com/microsoft/sqlserver/jdbc/SQLServerException.class
com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.class
com/microsoft/sqlserver/jdbc/SQLServerPooledConnection.class
com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement$PreparedHandleCloseRequest.class
com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement$PreparedStatementBatchExecutionRequest.class
com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement$PreparedStatementExecutionRequest.class
com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.class
com/microsoft/sqlserver/jdbc/SQLServerResource.class
com/microsoft/sqlserver/jdbc/SQLServerResource_de.class
com/microsoft/sqlserver/jdbc/SQLServerResource_es.class
com/microsoft/sqlserver/jdbc/SQLServerResource_fr.class
com/microsoft/sqlserver/jdbc/SQLServerResource_it.class
com/microsoft/sqlserver/jdbc/SQLServerResource_ja.class
com/microsoft/sqlserver/jdbc/SQLServerResource_ko.class
com/microsoft/sqlserver/jdbc/SQLServerResource_sv.class
com/microsoft/sqlserver/jdbc/SQLServerResource_zh_CN.class
com/microsoft/sqlserver/jdbc/SQLServerResource_zh_TW.class
com/microsoft/sqlserver/jdbc/SQLServerResultSet.class
com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.class
com/microsoft/sqlserver/jdbc/SQLServerSavepoint.class
com/microsoft/sqlserver/jdbc/SQLServerStatement$CloseServerCursorRequest.class
com/microsoft/sqlserver/jdbc/SQLServerStatement$CursorRowUpdateRequest.class
com/microsoft/sqlserver/jdbc/SQLServerStatement$StatementExecutionRequest.class
com/microsoft/sqlserver/jdbc/SQLServerStatement.class
com/microsoft/sqlserver/jdbc/SQLServerXAConnection.class
com/microsoft/sqlserver/jdbc/SQLServerXADataSource.class
com/microsoft/sqlserver/jdbc/SQLServerXAResource.class
com/microsoft/sqlserver/jdbc/StaticServerCursor.class
com/microsoft/sqlserver/jdbc/StreamColumns.class
com/microsoft/sqlserver/jdbc/StreamDone.class
com/microsoft/sqlserver/jdbc/StreamError.class
com/microsoft/sqlserver/jdbc/StreamLoginAck.class
com/microsoft/sqlserver/jdbc/StreamPacket.class
com/microsoft/sqlserver/jdbc/StreamRetValue.class
com/microsoft/sqlserver/jdbc/StreamSSPI.class
com/microsoft/sqlserver/jdbc/StreamUnrecognized.class
com/microsoft/sqlserver/jdbc/TDSVersion.class
com/microsoft/sqlserver/jdbc/TDSWriter.class
com/microsoft/sqlserver/jdbc/TypeInfo.class
com/microsoft/sqlserver/jdbc/UDTTDSHeader.class
com/microsoft/sqlserver/jdbc/Util.class
com/microsoft/sqlserver/jdbc/XAReturnValue.class
com/microsoft/sqlserver/jdbc/XidImpl.class
com/microsoft/sqlserver/jdbc/XMLTDSHeader.class
META-INF/manifest.mf
META-INF/zigbert.sf
META-INF/zigbert.rsa

Open in new window

0
MarkAuthor Commented:
Just tried 64bit Java 7 (1.7.0_71) and exact same problem. Is it possible the sqljdbc.jar has problems running on 64bit hosts?

The link you gave was for jdbc driver 4.0 or 4.1. I tried version 2.0 a couple of years ago and they had in fact changed many of the functions making the entire project unusable without rewriting the jdbc parts of every program! (for example select queries using stored procedures could return partial results, so the query and the try {} had to be rewritten for the new "feature") Given that I have nearly 300 .java and .jsp programs, I stuck with version 1.0.

Nevertheless, I will give that a shot.

Unless that works, or you or another EE expert can come up with a way to make jdbc work on 64bit hosts, I'll wipe and reinstall as 32bit -- which would be sad.
0
MarkAuthor Commented:
OK! Some success. I did download the sqljdbc 4.1 driver from the link you gave me, and both the 4.0 and 4.1 driver worked on the simple query I had. No bogus failed connection messages.

Now I'll try putting back Java 8, then see if it all works with Tomcat. Will post back results.
0
CEHJCommented:
Is it possible the sqljdbc.jar has problems running on 64bit hosts?
Yes, or more likely, code that it depends on. That's what i've been saying earlier.
0
MarkAuthor Commented:
Tested with javac/java (command line) and Tomcat -- everything works great! Thanks
0
CEHJCommented:
:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.