Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3230456
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:55:45+00:00 2026-05-17T16:55:45+00:00

When I run my project for the first time during an SBT session, it

  • 0

When I run my project for the first time during an SBT session, it throws the following exception when trying to access to a MySQL database:

java.lang.NoClassDefFoundError: scala/Ordered

When I run it again (and any time after it, during the same SBT session), it throws a different one:

java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/…

When I was using NetBeans, the same code was working Ok. Now, As I use SBT for building and Kate to edit and manage my project manually, I get these runtime errors.

MySQL JDBC driver (downloaded right from MySQL.com) JAR is in project’s lib directory and all the other libraries I’ve put there work ok.

Here is the code:

import java.sql._
...
// read
val dbc : Connection = DriverManager.getConnection("jdbc:mysql://localhost/...")
val st : Statement = dbc.createStatement
val rs : ResultSet = st.executeQuery("SELECT ...")
if(rs.first) result = rs.getDouble("field")
dbc.close
...
// write
val dbc : Connection = DriverManager.getConnection("jdbc:mysql://localhost/...")
val st : Statement = dbc.createStatement
st.execute("UPDATE ...")
dbc.close

I’ve seen a question that looks pretty related, but still no answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:55:46+00:00Added an answer on May 17, 2026 at 4:55 pm

    In the SBT project class there should be a line:

     // Declare MySQL connector Dependency
      val mysql = "mysql" % "mysql-connector-java" % "5.1.12"
    

    This will import the JDBC driver JAR file for MySQL.

    Did you load the driver? If you use this Util class to fetch the connections, the driver will be loaded exactly one time:

    // Util Class
    object DaoUtil {
      import java.sql.{DriverManager, Connection}
    
      private var driverLoaded = false
    
      private def loadDriver()  {
        try{
          Class.forName("com.mysql.jdbc.Driver").newInstance
          driverLoaded = true
        }catch{
          case e: Exception  => {
            println("ERROR: Driver not available: " + e.getMessage)
            throw e
          }
        }
      }
    
      def getConnection(dbc: DbConnection): Connection =  {
        // Only load driver first time
        this.synchronized {
          if(! driverLoaded) loadDriver()
        }
    
        // Get the connection
        try{
          DriverManager.getConnection(dbc.getConnectionString)
        }catch{
          case e: Exception  => {
            println("ERROR: No connection: " + e.getMessage)
            throw e
          }
        }
      }
    }
    

    The code is taken from a simple SBT – MySQL tutorial I wrote some time ago. If you want to download the complete tutorial, see http://github.com/ollekullberg/SimpleOrder

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Eclipse 3.4.1, moving my first steps. When I run my project (a
Is there a way to run a project inside a solution that has more
When I run a Test Project on Visual Studio I use the code below
a day before end of project i run into a complicated issue: i have
Under visual studio if you run a web project by pressing the Go button
Is there a way you can run your UnitTest project against a compiled DLL
I've been slowly working on a personnel project to run a webmud like game
I have findbugs plugin for eclipse which when run on my project will show
I run a rather complex project with several independent applications. These use however a
My Delphi7 project will not run on my clients computer if i don't have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.