Pessoal estou com os seguintes erros
Exception in thread "main" com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused: connect
STACKTRACE:
java.net.SocketException: java.net.ConnectException: Connection refused: connect
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2666)
at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at baixar.GerenciaBanco.Conectar_banco(GerenciaBanco.java:36)
at baixar.GerenciaBanco.inserir_numeros(GerenciaBanco.java:44)
at baixar.Main.main(Main.java:25)
** END NESTED EXCEPTION **
Last packet sent to the server was 31 ms ago.
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2741)
at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at baixar.GerenciaBanco.Conectar_banco(GerenciaBanco.java:36)
at baixar.GerenciaBanco.inserir_numeros(GerenciaBanco.java:44)
at baixar.Main.main(Main.java:25)
Java Result: 1
Minha Classe
package baixar;
import java.net.*;
import java.sql.*;
/**
*
* @author Isael Faria Junior
*/
public class GerenciaBanco {
private static final String URL = "jdbc:mysql://192.168.0.100/java_teste";
private static final String DRIVER = "com.mysql.jdbc.Driver";
private static final String USUARIO = "b";
private static final String SENHA = "b";
private String numero;
private String sql;
private Connection conn;
/** Creates a new instance of GerenciaBanco */
public GerenciaBanco(){
sql = new String();
numero = new String();
}
public void Conectar_banco() throws SQLException,ClassNotFoundException {
try{
Class.forName(DRIVER);
Connection conn = DriverManager.getConnection(URL,USUARIO, SENHA);
}
catch(ClassNotFoundException e){
System.out.println("Erro ao acessar o banco");
}
}
public void inserir_numeros(int numeros) throws SQLException, ClassNotFoundException{
this.Conectar_banco();
try{
Statement tabela = conn.createStatement(); // criando instancia de inserção.
String sql = "insert into numeros (nome) values(\""+numeros+")"; // String de inserção.
tabela.execute(sql);
tabela.close();
}
catch (SQLException e2) {
System.out.println("SQL ERRO...");
e2.printStackTrace();
}
catch (Exception e3) {
System.out.println("Erro de acesso");
e3.printStackTrace();
}
}
}