无法在添加产品方法中加载创建连接

Could not load create coonection in addProduct method

package com.Foodmart;

import javax.jws.*;

import java.sql.*;

@WebService(name = "FoodMart", serviceName = "FoodMartService", portName = "FoodMartHtt)
public class FoodmartWS {

    ProductDetails prod = new ProductDetails();

    @WebMethod(operationName = "check")
    public boolean Authenticate(String user, String pass) {
        PreparedStatement psmt = null;
        Connection c = null;
        try {
            c = ConnectionDB.getConnection();
            String selectSQL = "select * from Employee where Username=? and Password=?";
            psmt = c.prepareStatement(selectSQL);
            psmt.setString(1, user);
            psmt.setString(2, pass);
            psmt.executeQuery();
            c.close();
            return true;
        } catch (SQLException e) {
            return false;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

此方法在 AddProduct 中出错

    @WebMethod(operationName = "AddProduct")
    public ProductDetails ProdcutAdd(int prodid, double qty) {
        PreparedStatement preparedStatement = null;
        Connection con = null;
        try {
            System.out.println("try");

//here i am not able to create another one connection
            con = ConnectionDB.getConnection();
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Food", "root", "manager1");
            String selectSQL = "select Product_Id,Product_Name,Product_Price,Product_Qty from Products where Product_Id=?;";
            System.out.println("bbefore prepared");
            preparedStatement = con.prepareStatement(selectSQL);
            preparedStatement.setInt(1, prodid);
            System.out.println("before result set");
            ResultSet rs = preparedStatement.executeQuery();
            System.out.println("query Executed");
            rs.next();
            prod.setProductId(rs.getInt("Product_Id"));
            prod.setProductName(rs.getString("Product_Name"));
            prod.setProductPrice(rs.getDouble("Product_Price"));
            prod.setProductQty(rs.getInt("Product_Qty"));
            System.out.println("obj set");
            con.close();
            System.out.println("in" + prod);
            return prod;
        } catch (SQLException e) {
            System.out.println(e);
            return null;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }

为什么在连接后添加此行:

con = ConnectionDB.getConnection();
//con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Food", "root", "manager1");

所以删除它或评论它。

备注 你最后在这里错过了一个 "),所以这也会造成问题:

@WebService(name = "FoodMart", serviceName = "FoodMartService", portName = "FoodMartHtt)

希望对您有所帮助。