2
I’m trying to make a connection to java directly with jdbc. I inserted the mysql jar jdbc into the project properties, javabuildpath and adding the external jar. I am making the following example and it seems to me that it does not find the bank.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Disciplina {
private int idDisciplina;
private String disciplina;
private float cargaHoraria;
public static void main(String args[]) throws SQLException {
Connection conexao = DriverManager
.getConnection("jdbc:mysql://localhost/ucsal");
System.out.println("Conectado!");
conexao.close();
}
}
Note: throws exception, I will not treat because I want to see the error. And about the inserted jar, when I go in javabuildpatch, in the library tab, mysql jdbc has nothing inside the library. Everything is None (source target "None", java doc Location "None", Native library Location "None").
I just downloaded the jar, didn’t download the rest of the contents of the mysql_jdbc.zip folder.
Ok, it worked. Now I’m already doing the query’s. Gratro.
– André Nascimento
@Andrénascimento, blz. Now just mark as answer to the question. :)
– Marcos Sousa