Announcement Announcement Module
No announcement yet.
STS - Maven - JTDS - ClassNotFoundException Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • STS - Maven - JTDS - ClassNotFoundException

    I currently am using STS and have the Maven extension installed. I've got a Maven project setup and I'm trying to use jtds to access a SQL Server.

    I've used the command
    mvn install:install-file -Dfile=<local path> -DgroupId="net.sourceforge.jtds" -DartifactId="jtds" -Dversion="1.2.5" -Dpackaging="jar"
    to install the jtds jar in Maven and added the following to the POM file to make the matching reference.

    I'm using the following bit of groovy code to connect to the Database.

    def db = [url: 'jdbc:jtds:sqlserver://<testserver>:1433/<testdatabase>', username: <testuser>, password: <testpassword>,
    driver: 'net.sourceforge.jtds.jdbc.Driver']
    def sql = Sql.newInstance(db.url, db.username, db.password, db.driver)
    def rows = sql.rows('SELECT * FROM dbo.Rate')
    Unfortunately I keep getting a ClassNotFoundException on net.sourceforge.jtds.jdbc.Driver. I've tried several tweaks on the code, but I'm constantly running into a ClassNotFoundException error. I'd appreciate some assistance figuring out what I'm missing.

    Thanks! Faile

  • #2
    Solution found - Although I had added the jar to the class path and the pom under the pom.xml tab, it was also necessary to add it to the pom under the Dependencies tab.