找不到合适的jdbc驱动程序:mysql://mudfoot.doc.stu.mmu.ac.uk/
这是我收到的错误。我正在尝试连接到我的数据库以添加有关课程的新信息。下面是我的CourseAdd.java的代码。它从html文件中获取参数,然后尝试添加信息。请帮忙 !!! 我在库中有JDBC驱动程序
**package course_14024632;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/CourseAdd")
public class CourseAdd extends HttpServlet {
private static final long serialVersionUID = 1L;
public CourseAdd() {
super();
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//this adds a new recording into the database
//under the table called Music_Recordings
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<header> <link rel = \"stylesheet\" href= \"style1.css\" /> </header>");
//links to the stylesheet
String r = request.getParameter("courseid");
String a = request.getParameter("coursename");
String t = request.getParameter("coursecredits");
String c = request.getParameter("courseduration");
String i = request.getParameter("coursetutor");
//gets all the parameters
String insertSQL = "insert into Course values('+r+','+a+','"+t+"','"+c+"','+i+')";
//creates an SQL statement
Connection conn =null; // Create connection object so it can connect to the database
String database = "*database name*"; // Name of the database
String user = "*username*"; //name of the username
String password = "*password*"; //and password
String url = "jdbc:mysql://mudfoot.doc.stu.mmu.ac.uk/" + database;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch(Exception e) { System.out.println(e); }
// connecting to database
try{
conn = DriverManager.getConnection(url, user, password);
}
catch(SQLException se) {
System.err.println(se);
}
// Create select statement and execute it
try{
Statement stmt = conn.createStatement();
int success = stmt.executeUpdate(insertSQL);
if(success<1){
System.out.println("update failed!");
}
//executes the statement created earlier and closes
//conneciton to the database
conn.close();
}catch(SQLException se) {
System.err.println(se);
}
doGet(request, response);
}
}**