3 messages in com.mysql.lists.javaconection refused| From | Sent On | Attachments |
|---|---|---|
| piuras | 10 Jul 2004 16:31 | |
| Igor Smirnov | 12 Jul 2004 00:28 | |
| Keith Hatton | 12 Jul 2004 04:38 |
| Subject: | conection refused![]() |
|---|---|
| From: | piuras (piu...@ig.com.br) |
| Date: | 07/10/2004 04:31:47 PM |
| List: | com.mysql.lists.java |
Someone can help me to understant what is wrong in code below, becouse I recieve a message : "conection refused" , when I try to test de program ? PS: I can conect into the dababase with this command line: mysql -h localhost -u sa -p, and the passord "sa"
/Teste de conexão
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException;
// Notice, do not import com.mysql.jdbc.* // or you will have problems!
public class LoadDriver { public static void main(String[] args) { try { // The newInstance() call is a work around for some // broken Java implementations
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) { // handle the error System.out.println("Erro no registro do Driver Mysql!!!!"); }
try { // The newInstance() call is a work around for some // broken Java implementations Connection conn = DriverManager.getConnection("jdbc:mysql:///localhost:3306/web?user=sa&password=sa");
} catch (SQLException ex) { // handle the error System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode());
}
}




