Addman Addman - 2 months ago 6x
MySQL Question

Connecting to MySQL Database from java in IDE Netbeans

So this is my thing. I am trying to connect do MySQL Database from java. I have downloaded connector driver from MySQL ( Its called "mysql-connector-java-5.0.8-bin.jar" ) and I added to my libraries (Im using NetBeans). I tried to do simple connection like this:

package datacon;

public class Datacon {

public static void main(String[] args) {

try {

java.sql.Connection con = (java.sql.Connection) java.sql.DriverManager
/*, "root"
, "root" */ );

} catch ( Exception e ) {
System.out.println( e.toString() );

But this hapened:

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

I made my research on the internet and this pretty common thing, but none of the answers helped me. I was able connect to database through NetBeans/services, so that URL jdbc:mysql://localhost:3306/test should be correct.

I am using:

java: Oracle java SDK 1.7.0 _ 45
IDE: NetBeans 7.4
OS: Debian 3.2.51-1 x86_64
Driver: MySQL Connector/J 5.0.8

I am afraid this is gonna have a very trivial answer, but I am stuck here for a while now and i need to move. So what am I missing?



static {
    try {
    } catch (final ClassNotFoundException e) {