Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
- }
- 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;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement