Database Driver not found / Connection refused

Just downloaded TeamCity 5.1.2.  Created a database in Sql Server 2008 and connected using the credentials I put in properties file. The jtds jar is in the directory indicated in the installation help files.

Here is the error I get in the teamcity-server.log

[2010-07-05 14:18:42,500]  ERROR -   jetbrains.buildServer.SERVER - Server startup exception: jetbrains.buildServer.rootDispatcher.KnownRecoverableStartupError: Database driver not found:
Could not connect to Microsoft SQL server.
Connection refused: connect
SQL exception: Network error IOException: Connection refused: connect

So.... which is it?  Did it not find the driver?  Or did it find the driver and couldn't connect?  I double-checked all the port settings etc and I *can* connect from SSMS using the same info I am supplying so I am mystified.

Thanks,

Matt

5 comments
Comment actions Permalink

Turns out it was a named instance problem with the driver.  From the jTDS documentation:

Q- Where does one place an instance name in the connect string? Connecting with

"jdbc:jtds:sqlserver://host\instance:port/database"
gives an SQLException with the message "Logon failed".

A- You will have to use the

instance
property (either append it to the URL or place it into the
Properties
you supply to
getConnection
) instead of doing it the Microsoft way. Sorry, but jTDS (and its ancestor FreeTDS) existed a long time before named instances so the URL could not be changed (and using it this way confuses the URL parser).

Two thoughts on this for the folks on the TeamCity project.  First, since jTDS has "existed a long time" and apparently doesn't have a flexible code base, is there an argument to be made for supporting a driver from Microsoft?  I know they are the evil giant and all... but they WERE agile enough to figure out how to change their URL parser.   

Next, is there a way to get the logger to emit better error messages?  Telling me that you can't find the driver and then telling me that the connection was refused leads me to believe that TeamCity simply can't find the .jar.  I spent quite a bit of time trying to ensure that the file was in the right place and that all the permissions were correct etc before my colleague suggested that maybe it was a named instance problem.  Better error messages are good for the blood pressure!

Thanks,

Matt

0
Comment actions Permalink

Hello Matt,

> The jtds jar is in the directory indicated in the installation help files.

which directory?

Please place the JTDS jar into the <TC_DATA_DIR>/lib/jdbc directory - this should help (since TC 5.1).

Best regards,
Leonid

0
Comment actions Permalink

Hello Matt,

you can provide parameters to JTDS driver using the 'database.properties' file. Just add the property with prefix 'connectionProperties.'. For example, for adding property named foo with value bar you can add the following line:

    connectionProperties.foo=bar

Don't forget that backslash in the file is treated as an escape character (you can type backslash twice for adding backslash).

As of native jdbc dirver for MS SQL - you can post an issue into our issue tracker (http://youtrack.jetbrains.net).

> Telling me that you can't find the driver and then telling me that the connection was refused leads me to believe that TeamCity simply can't find the .jar.

It looks right.

> I spent quite a bit of time trying to ensure that the file was in the right place

Which place is right?


Best regards,
Leonid

0
Comment actions Permalink

The correct directory is <TeamCity data directory>/lib/jdbc as specified in the documentation.  This is where the file was and yet the log reported that TeamCity could not find the driver.

The second error message was actually more accurate, namely that it could not connect to SQL Server.

To clarify, I did get things working but only after reading the jTDS documentation on using named instances.  You guys should probably cover this in your documentation as well.  Thanks for the response!

0
Comment actions Permalink

Hi Matt,

thanks you for the information about this case. I've posted a new issue http://youtrack.jetbrains.net/issue/TW-12710 you can vote it.

Best regards,
Leonid

0

Please sign in to leave a comment.