No suitable driver found for jdbc:jtds:sqlserver
Asked Answered
N

4

5

I have explored similar questions, but none of them seem to be the same situation. I have a REST application deployed to the JBOSS 7.1.1 server. I am using JPA. Whenever I make a call in the EntityManager, I get the following error in the server:

15:16:39,024 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--0.0.0.0-8080-1) No suitable driver found for jdbc:jtds:sqlserver://aicdevapp01:1433/MOD_Normal

Within the <datasources> tag in the configuration file of the standalone mode of the JBOSS server, I have the following lines of code:

<drivers>
    <driver name="mssql" module="net.sourceforge.jtds">
    <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
    <xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</xa-datasource-class>
     </driver>
 </drivers>

Any pointers on where I should be looking at to solve this problem? I can hit the database when I run maven tests, but whenever I deploy to the server I have that problem.

Nonpareil answered 20/3, 2015 at 11:20 Comment(1)
You need to add it as module in Jboss. check <JBOSS_HOME>/modules it should be added as module in net\sourceforge.Demosthenes
R
6

You have to download jtds.jar and add it to your classpath.

Reverence answered 20/3, 2015 at 11:22 Comment(3)
I will do so. If it works I will accept answer. Thanks a lot!Nonpareil
I added it to the Windows CLASSPATH environmental variable, but still no luck. I also deployed it together with the ear file and no luck. What else should I attempt?Nonpareil
Have you put it in the "WEB-INF/lib" of your war?Reverence
V
2

If using jtds directly i.e.:

Driver.getConnection(url, username, password);

Then use:

Class.forName("net.sourceforge.jtds.jdbc.Driver");

Else if using a DataSource like for HikariCP use:

setDriverClassName("net.sourceforge.jtds.jdbc.Driver");

As in:

private HikariConfig config = new HikariConfig();
config.setDriverClassName("net.sourceforge.jtds.jdbc.Driver");
Vidette answered 12/1, 2019 at 11:1 Comment(1)
Class.forName("net.sourceforge.jtds.jdbc.Driver"); this working for me. BTW, I am not a professional java developer. Thnx +10Strawn
T
0

to add the jtds.jar into the classpath via IDE such as IntelliJ, follow below how to add directory to classpath in an application run profile in intellij idea?

more info here: https://confluence.jetbrains.com/display/IDEADEV/Structure+of+IntelliJ+IDEA+Project#StructureofIntelliJIDEAProject-HowdoIgetdependenciesandclasspathofamodule%3F

And it is recommended (if you use SBT) to save the un-managed jar in the lib directory of the project. see: http://www.scala-sbt.org/0.13/tutorial/Library-Dependencies.html

Teletype answered 17/7, 2015 at 2:53 Comment(0)
M
0

It's also available on Maven Central, so in case the project uses Maven, you can just add the following to your pom.xml (note that the version may be higher when you read this):

<!-- https://mvnrepository.com/artifact/net.sourceforge.jtds/jtds -->
<dependency>
    <groupId>net.sourceforge.jtds</groupId>
    <artifactId>jtds</artifactId>
    <version>1.3.1</version>
</dependency>
Muley answered 16/1, 2018 at 15:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.