0

So i have done a bunch of java programming but this is my first time using a database in an application.

I am using intellij and MySQL

Now i made a simple application to store a random word. The computer i made this application on works perfectly. i can type a word, click save, close the program and the word will reappear the next time i run the program.

However, using this program on another computer i will get the following error

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

How do i make this program work on any other computer

here is some of the code to connect to the database

public class ConnectionConfiguration {

public static Connection getConnection() {
    Connection connection = null;
    try {
        Class.forName("com.mysql.jdbc.Driver");
        connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/testDatabase", "root", "qwerty");
    } catch (Exception e) {
        e.printStackTrace();
    }
    return connection;
}
}

Thanks!

cmptUser
  • 51
  • 1
  • 10

1 Answers1

0

-Change "localhost" to IP (your computer got DB) -Extract your jar(mysql) to your jar file(check my last answer in your topic).