2020-11-05解宝世

public static void save() throws Exception {
//1、加载数据库驱动
Class.forName("com.mysql.jdbc.Driver");
//2、创建数据库连接
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/db_user","root","");
//3、拼写sql语句
String sql = "INSERT INTO t_user (userName,passWord,gender)VALUES('李白','rb123','女')";
//4、发送sql
PreparedStatement prepareStatement = connection.prepareStatement(sql);
//5、执行sql
int i = prepareStatement.executeUpdate();
//6、处理结果
if(i > 0) {
System.out.println("添加成功")
}
//7、关闭资源
prepareStatement.close();
connection.close();
服务器与web的连接
新建一个文件-new-other-web-dynanic web project-shopping-
next-next-对号-finish
java resources-src-右键-new-package-com.itlaobing.dbhelper
-右键-class-DBHelper
java resources和webcontent中复制HTML中的文件的复制到esp中
content-other-jsp-file-index.jsp-finish
window-最后-server-runtime-add-apache9.0-找目录文件的路径
-finish-apply and close
buid path-configur-lib-addlib-server runtime-选中Apache9.0-a
pply and close
server-右键-and remove-shopping
window-preperences-web-jsp files-utf_8-apply and close
window-preperences-other-utf_8
再将html改成jspwindow-preperences-server-runtime environm
ents-add-9.0-next-路径-finish-apply and close

心得体会:进行服务器与客户端的查询操作,环境配置等操作,环境配置没有成功。
这两天的学习效果自我感觉不是那么好,但是依旧在学习中。

标签

评论

© 2021 成都云创动力科技有限公司 蜀ICP备20006351号-1