2016-08-04 2 views
0

문제가 있습니다.DB conexion Mysql Xampp

나는 이미 PHPmyadmin을 사용하여 DB를 만들고 Xampp을 사용하여 로컬 호스트를 생성하지만 내 DB에 연결하려고하면 IDE가 연결을 만들지 않고 어떤 종류의 오류도 보내지 않습니다. IDE와 똑같은 생각을 계속합니다. 내가 잘못 연결했는지 모르겠다. 내가 너를 도울 수 있기를 바란다.

내가 클래스 DB_Connection

package restaurantelospavorreales; 
import java.util.LinkedList; 
import java.sql.*; 
import javax.swing.JOptionPane; 

/** 

* @author luisricardo 
*/ 
public class BuscarProducto { 
    public LinkedList Producto(int Identificador, String Tipo, int Cantidad, int Mesa){ 
     LinkedList Datos = new LinkedList(); 
     Datos.add(Mesa); 
     String Query; 
     Query = "SELECT ID, Nombre, Precio FROM '" + Tipo + "' WHERE ID = " + Identificador ;  //Se construye el Query 
     //Se realiza la conexion 
     try { 
      ResultSet Res = new DB_Conecttion().Conexion().createStatement().executeQuery(Query); 

      Datos.addLast(Res.getString(1)); 
      Datos.addLast(Res.getString(2)); 
      Datos.addLast(Res.getString(3)); 

     } catch (Exception e) { 
      JOptionPane.showMessageDialog(null,"Error en la conexion a la DB :" + e); 
     } 

     return Datos; 
    } 
} 

답변

-1

사용하는 IDE의 인스턴스를 만들 어디가 연결 여기

package restaurantelospavorreales; 
import java.sql.*; 
import javax.swing.JOptionPane; 

/** 
* 
* @author luisricardo 
*/ 
public class DB_Conecttion { 
    public Connection Conexion(){ 
     Connection Con = null; 
     try { 
      Class.forName("com.mysql.jdbc.Driver"); 
      Con = DriverManager.getConnection("jdbc:mysql://localhost:8080/pavorreales", "root", ""); 
     } catch (Exception e) { 
      JOptionPane.showMessageDialog(null, "Se presento el error: " + e); 
     } 
     return Con; 
    } 
} 

을 클래스 이잖아? IDE가 방화벽이나 뭔가에 의해 localhost에서 연결되는 것을 방지하는 것과 같은 문제가 있습니다.

+0

NetBeans를 사용하고 있으며 이미 방화벽을 끄고 문제가 계속 발생합니다. –

+0

연결 문자열을 변경하면 오류가 발생합니다. –