Java 未知sql查询

Java 未知sql查询,java,mysql,Java,Mysql,我试图运行在internet上找到的这个项目,但我在netbeans“com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:PROCEDURE contactos.sp_guardar不存在”中发现了这些错误,它们是由以下两个查询导致的: 更新数据库 String sql=“调用sp_guardar(?,,,,?,?)” 搜索数据库 字符串sql=“调用总线(?” 我正在使用一个通过xammp连接的mysql数据库 项目的代码 pac

我试图运行在internet上找到的这个项目,但我在netbeans“com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:PROCEDURE contactos.sp_guardar不存在”中发现了这些错误,它们是由以下两个查询导致的:

更新数据库

String sql=“调用sp_guardar(?,,,,?,?)”

搜索数据库

字符串sql=“调用总线(?”

我正在使用一个通过xammp连接的mysql数据库

项目的代码

package contactosfx;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

public class AmigoDao implements AmigoInterface {


public AmigoDao(){

}

@Override

//UPDATE DB
public void guardar(Amigo amigo) {
    Connection con = Conexion.conectar();
    CallableStatement cs = null;
    String sql = "call sp_guardar(?,?,?,?,?)";


    try {
        cs = con.prepareCall(sql);
        cs.setString(1, amigo.getFoto());
        cs.setString(2, amigo.getNombre());
        cs.setString(3, amigo.getCorreo());
        cs.setString(4, amigo.getTelf());
        cs.setInt(5, amigo.getEstado());
        cs.executeUpdate();
        cs.close();
        con.close();

    } catch (SQLException ex) {
        ex.printStackTrace();
    } finally {
        try {
            if (con != null) {
                cs.close();
                con.close();
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }
}

@Override
public void actualizar(Amigo amigo, int id) {
    Connection con = Conexion.conectar();
    CallableStatement cs = null;
    //String sql = "call sp_actualizar(?,?,?,?,?,?)";


    try {
        cs = con.prepareCall(sql);
        cs.setString(1, amigo.getFoto());
        cs.setString(2, amigo.getNombre());
        cs.setString(3, amigo.getCorreo());
        cs.setString(4, amigo.getTelf());
        cs.setInt(5, amigo.getEstado());
        cs.setInt(6, id);
        cs.executeUpdate();

    } catch (SQLException ex) {
        ex.printStackTrace();
    } finally {
        try {
            if (!con.isClosed()) {
                cs.close();
                con.close();
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }

}

@Override
public ObservableList<Amigo> buscar(String nombres) {
    Connection con = Conexion.conectar();
    CallableStatement cs = null;
    ResultSet rs = null;
    ObservableList<Amigo> lista = FXCollections.observableArrayList();
    String sql = "call buscar(?)";
    //String sql = "call search(?)";

    try {
        cs = con.prepareCall(sql);
        cs.setString(1, nombres);
        rs = cs.executeQuery();
        while(rs.next()){
            lista.add(new Amigo(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getInt(6)));
        }

    } catch (SQLException ex) {
        ex.printStackTrace();
    }
    return lista;
}

@Override
public ObservableList<Amigo> buscarHabilitados() {
    Connection con = Conexion.conectar();
    Statement st = null;
    ResultSet rs = null;
    String sql = "select*from habilitados";
    ObservableList<Amigo> lista = FXCollections.observableArrayList();
    try {
        st = con.createStatement();
        rs = st.executeQuery(sql);

        while (rs.next()) {
            lista.add(new Amigo(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5), rs.getInt(6)));
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return lista;
}

@Override
public ObservableList<Amigo> buscarDeshabilitados() {
    Connection con = Conexion.conectar();
    Statement st = null;
    ResultSet rs = null;
    String sql = "select*from deshabilitados";
    ObservableList<Amigo> lista = FXCollections.observableArrayList();
    try {
        st = con.createStatement();
        rs = st.executeQuery(sql);

        while (rs.next()) {
            lista.add(new Amigo(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5), rs.getInt(6)));
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return lista;

}
package contactosfx;
导入java.sql.CallableStatement;
导入java.sql.Connection;
导入java.sql.ResultSet;
导入java.sql.SQLException;
导入java.sql.Statement;
导入javafx.collections.FXCollections;
导入javafx.collections.ObservableList;
公共类AmigoDao实现AmigoInterface{
公共阿米戈多(){
}
@凌驾
//更新数据库
公共空间(朋友,朋友){
连接con=Conexion.conectar();
CallableStatement cs=null;
String sql=“调用sp_guardar(?,,,,?,?)”;
试一试{
cs=con.prepareCall(sql);
cs.setString(1,amigo.getFoto());
cs.setString(2,amigo.getNombre());
cs.setString(3,amigo.getCorreo());
cs.setString(4,amigo.getTelf());
cs.setInt(5,amigo.getEstado());
cs.executeUpdate();
cs.close();
con.close();
}catch(SQLException-ex){
例如printStackTrace();
}最后{
试一试{
如果(con!=null){
cs.close();
con.close();
}
}catch(SQLException-ex){
例如printStackTrace();
}
}
}
@凌驾
公共虚拟现实(Amigo Amigo,int id){
连接con=Conexion.conectar();
CallableStatement cs=null;
//String sql=“调用sp_实现(?,,,,,,,,?)”;
试一试{
cs=con.prepareCall(sql);
cs.setString(1,amigo.getFoto());
cs.setString(2,amigo.getNombre());
cs.setString(3,amigo.getCorreo());
cs.setString(4,amigo.getTelf());
cs.setInt(5,amigo.getEstado());
cs.setInt(6,id);
cs.executeUpdate();
}catch(SQLException-ex){
例如printStackTrace();
}最后{
试一试{
如果(!con.isClosed()){
cs.close();
con.close();
}
}catch(SQLException-ex){
例如printStackTrace();
}
}
}
@凌驾

public observebleList

这些是代码编写者认为会存在于数据库中的存储过程。显然,它们不是。要使其正常工作,您需要实现
sp_guardar
和可能的
buscar
存储过程,或者从代码中删除它们。

好的,我如何在没有影响其功能?您必须弄清楚您的方法在数据库中应该做什么,并确保所有这些功能都已实现。如果您可以在不调用数据库的情况下实现所有这些功能,请删除存储过程调用。如果您需要调用数据库,则需要实现应用程序e存储过程。这是项目的链接获取缺少的存储过程或提供链接以便有人可以检查它