java.sql.SQLException: No suitable driver found for jdbc:mysql://127.0.0.1/m
在eclipse中编写了一个注册的界面。但是无论提交的是什么,提示的错误都是:该会员名已被使用,请您更换名字java.sql.SQLException:Nosuitabl...
在eclipse中编写了一个注册的界面。但是无论提交的是什么,提示的错误都是:该会员名已被使用,请您更换名字java.sql.SQLException: No suitable driver found for jdbc:mysql://127.0.0.1/makefriend?user=root&password=&characterEncoding=gb2312
try{
logname=handleString(logname);
password=handleString(password);
phone=handleString(phone);
//email=handleString(email);
// message=handleString(message);
String pic="public.jpg";
String insertRecord="('"+logname+"','"+password+"','"+phone+"','"+pic+"')";
String uri="jdbc:mysql://127.0.0.1/makefriend?"+
"user=root&password=&characterEncoding=gb2312";
con=DriverManager.getConnection(uri);
String insertCondition="INSERT INTO member VALUES "+insertRecord;
sql=con.createStatement();
if(boo){
int m=sql.executeUpdate(insertCondition);
if(m!=0){
backNews="注册成功";
reg.setBackNews(backNews);
reg.setLogname(logname);
reg.setPassword(password);
reg.setPhone(phone);
//reg.setEmail(email);
//reg.setMessage(message);
}
}
else{
backNews="信息填写不完整或名字中有非法字符";
reg.setBackNews(backNews);
}
con.close();
}
catch(SQLException exp){
backNews="该会员名已被使用,请您更换名字"+exp;
reg.setBackNews(backNews);
}
RequestDispatcher dispatcher=
request.getRequestDispatcher("showRegisterMess.jsp");//转发
dispatcher.forward(request,response);
}
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
doPost(request,response);
}
} 展开
try{
logname=handleString(logname);
password=handleString(password);
phone=handleString(phone);
//email=handleString(email);
// message=handleString(message);
String pic="public.jpg";
String insertRecord="('"+logname+"','"+password+"','"+phone+"','"+pic+"')";
String uri="jdbc:mysql://127.0.0.1/makefriend?"+
"user=root&password=&characterEncoding=gb2312";
con=DriverManager.getConnection(uri);
String insertCondition="INSERT INTO member VALUES "+insertRecord;
sql=con.createStatement();
if(boo){
int m=sql.executeUpdate(insertCondition);
if(m!=0){
backNews="注册成功";
reg.setBackNews(backNews);
reg.setLogname(logname);
reg.setPassword(password);
reg.setPhone(phone);
//reg.setEmail(email);
//reg.setMessage(message);
}
}
else{
backNews="信息填写不完整或名字中有非法字符";
reg.setBackNews(backNews);
}
con.close();
}
catch(SQLException exp){
backNews="该会员名已被使用,请您更换名字"+exp;
reg.setBackNews(backNews);
}
RequestDispatcher dispatcher=
request.getRequestDispatcher("showRegisterMess.jsp");//转发
dispatcher.forward(request,response);
}
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
doPost(request,response);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询