我正在尝试使用端点在eclipse中使用tomcat 7作为服务器来质疑mysql数据库,但它总是给我这个错误,有人用jdbi解决了这个问题吗
类型异常报告
消息 java.sql.SQLException:找不到适合 jdbc 的驱动程序:mysql://127.0.0.1/demo
The code:
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import org.json.JSONException;
import org.json.JSONObject;
import org.skife.jdbi.v2.DBI;
import org.skife.jdbi.v2.Handle;
@Path("/jdbiservice")
public class JdbiService {
@Path("{f}")
@GET
@Produces("application/json")
public Response convertFtoCfromInput(@PathParam("f") int f) throws JSONException {
DBI dbi = new DBI("jdbc:mysql://127.0.0.1/demo", "user", "pass");
Handle h = dbi.open();
BatchExample b = h.attach(BatchExample.class);
Something s =b.findById(f);
h.close();
JSONObject jsonObject = new JSONObject(s);
String result = jsonObject.toString();
return Response.status(200).entity(result).build();
}
}
您好,在 Eclipse 项目路径和 tomcat lib 文件夹中有 jar 连接器文件。