日期:2014-05-17 浏览次数:21006 次
request.setCharacterEncoding("UTF-8");
String title = request.getParameter("title");
String data = request.getParameter("data");
System.out.println(data);
String massage = request.getParameter("massage");
Connection conn = null;
Statement stat = null;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/ranju";
String user = "root";
String password = "123";
conn = DriverManager.getConnection(url, user, password);
stat = conn.createStatement(); //这句报错
String sql = "insert into xinwen values(" + title + ",'" + data + "'," + massage + ")";
stat.executeUpdate(sql);
rs = stat.executeQuery("select * from xinwen");