No suitable driver found for jdbc:jtds:sqlserver

12,133

Solution 1

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

Solution 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");
Share:
12,133
Jadiel de Armas
Author by

Jadiel de Armas

Check the videoflow library: (https://github.com/videoflow/videoflow)

Updated on June 13, 2022

Comments

  • Jadiel de Armas
    Jadiel de Armas almost 2 years

    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.

    • Neeraj
      Neeraj about 9 years
      You need to add it as module in Jboss. check <JBOSS_HOME>/modules it should be added as module in net\sourceforge.
  • Jadiel de Armas
    Jadiel de Armas about 9 years
    I will do so. If it works I will accept answer. Thanks a lot!
  • Jadiel de Armas
    Jadiel de Armas about 9 years
    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?
  • Jens
    Jens about 9 years
    Have you put it in the "WEB-INF/lib" of your war?
  • Shahzad Barkati
    Shahzad Barkati almost 2 years
    Class.forName("net.sourceforge.jtds.jdbc.Driver"); this working for me. BTW, I am not a professional java developer. Thnx +10