[25分] 求大侠帮忙解决数据插入问题 [25分]
1. conn.jsp
<%
//驱动程序名
String driverName= "com.mysql.jdbc.Driver ";
//数据库用户名
String userName= "root ";
//密码
String userPasswd= "123 ";
//数据库名
String dbName= "myNote ";
//联结字符串
String url= "jdbc:mysql://localhost/ "+dbName+ "?user= "+userName+ "&password= "+userPasswd;
Class.forName( "com.mysql.jdbc.Driver ").newInstance();
Connection connection=DriverManager.getConnection(url);
Statement statement = connection.createStatement();
//获得数据结果集合
//ResultSetMetaData rmeta = rs.getMetaData();
//确定数据集的列数,亦字段数
//int numColumns=rmeta.getColumnCount();
%>
2 add_data.jsp
<%@ page contentType= "text/html; charset=gb2312 " %>
<%@ page language= "java " %>
<%@ page import= "com.mysql.jdbc.Driver " %>
<%@ page import= "java.sql.* " %>
<%@ include file= "conn.jsp "%>
<html>
<head>
</head>
<body>
<%
//定义接受变量的参数
String user_name;
String user_email;
String user_qq;
String user_mob_no;
String user_tel;
String user_add;
//获取参数
user_name = request.getParameter( "User_name ");
user_email = request.getParameter( "user_email ");
user_qq = request.getParameter( "user_qq ");
user_mob_no = request.getParameter( "user_mob_no ");
user_tel = request.getParameter( "user_tel ");
user_add = request.getParameter( "user_add ");
//test
out.print( "user nam: " + user_name + " <br> ");
out.print( "user email: " + user_email + " <br> ");
out.print( "user qq: " + user_qq + " <br> ");
out.print( "user mobile: " + user_mob_no + " <br> ");
out.print( "user tel: " + user_tel + " <br> ");
out.print( "user add: " + user_add + " <br> ");
//sql语句
String sql= "INSERT INTO phone_book(name,email,qq,mobile_no,telephone,address) VALUES( ' " + user_name + " ', ' " + user_email + " ', ' " + user_qq + " ', ' " + user_mob_no + " ', ' " + user_tel + " ', ' " + user_add + " ') ";
out.print( "sql " + sql);
statement.executeQuery(sql);
statement.close();
connection.close();
%>
</body>
</html>
问题: sql语句正确,
&n