Mesho
Mesho

Reputation: 45

connection with mysql database

i have problem in connection NetBeans with MySQL

you can see the image:

image .

every thing I think is right but when I run the program it gives me error in connection and i am sure about the user and pass

can you help me ?

Upvotes: 1

Views: 100

Answers (2)

maxammann
maxammann

Reputation: 1048

You need the mysql connector for java: http://www.mysql.de/downloads/connector/j/

Just add this as dependency/lib and add this to your compilation output so the classes from the connector are included in your final .jar file. Not sure how this works with NetBeans but it should be very easy to include it.

EDIT: maybe it's enough to just add the library to your project to run it, but in your final .jar file you want to share maybe you need to add the classes.

Upvotes: 0

John Woo
John Woo

Reputation: 263713

how about this?

String connStr = "jdbc:mysql://localhost/cooffee?user=root&password=root";
Connection conn = DriverManager.getConnection(connStr);

Upvotes: 1

Related Questions