Solved

Trouble getting sqljdbc program running with new Java

Posted on 2014-12-12
10
279 Views
Last Modified: 2014-12-15
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?
0
Comment
Question by:jmarkfoley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 40497709
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
 
LVL 1

Author Comment

by:jmarkfoley
ID: 40498111
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
 
LVL 1

Author Comment

by:jmarkfoley
ID: 40498143
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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 40498257
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
 
LVL 1

Author Comment

by:jmarkfoley
ID: 40498401
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
 
LVL 1

Author Comment

by:jmarkfoley
ID: 40498441
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
 
LVL 1

Author Comment

by:jmarkfoley
ID: 40498547
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 40498789
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
 
LVL 1

Author Comment

by:jmarkfoley
ID: 40499628
Tested with javac/java (command line) and Tomcat -- everything works great! Thanks
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 40499951
:)
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question