Guys I am trying to develop a simple authentication application in java by using RESTful and MySQL.
For the Server i'm using the following code
import java.sql.Connection;
import java.sql.DriverManager;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
// http://localhost:8080/2.ServerUserAPI/rest/User?Username=david
@Path("/User")
public class Main{
@GET
@Produces(MediaType.TEXT_PLAIN)
public String sayPlainTextHello(@QueryParam("Username") String Username) throws Exception{
try{
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/CloudDB", "root", "eusgr1");
PreparedStatement statement = con.prepareStatement("SELECT Username FROM UserAuthentication");
}
catch (Exception e){
throw e;
}
return "qwer";
}
}
But I get the following error: No suitable driver found for jdbc:mysql://localhost/CloudDB
I have included the jar file for mysql Also i have included the jars for jersey.
When i try this by placing comments for the:
//Connection con = DriverManager.getConnection("jdbc:mysql://localhost/CloudDB", "root", "eusgr1");
It works great on the server. Also when in a different class to make the connection by using public static void main{ ... connection ...}
again it works.
How can i combine these two (RESTful and MySQL) ??
Thank you for you help.