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.

Jadiel de Armas
  • 8,405
  • 7
  • 46
  • 62
  • You need to add it as module in Jboss. check /modules it should be added as module in net\sourceforge. – Neeraj Mar 27 '15 at 07:17

4 Answers4

6

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

Jens
  • 67,715
  • 15
  • 98
  • 113
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");
סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
Joseph Waweru
  • 1,680
  • 18
  • 14
  • `Class.forName("net.sourceforge.jtds.jdbc.Driver");` this working for me. BTW, I am not a professional java developer. Thnx +10 – Shahzad Barkati Jun 07 '22 at 09:29
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

Community
  • 1
  • 1
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>
Scadge
  • 9,380
  • 3
  • 30
  • 39