20201104白岩龙

知识总结:
一、知识总结
(1)把apache-tom集成到开发环境
(2)新建项目
新建一个文件-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中,及将文件放到javaresource
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
serve右键-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
package com. laobing. dbh;
import java. sq1. Connection;·
public class DBhelper {
/lmain28l/
public static void main(String[] args) {try {
save();
} catch (Exception e) {
e. printStackTrace();
}
! eaaa2288028kE2 1
public static void save() throws Exception {
1 /019000000100000
C1ass. forName("com. mysq1.jdbc.Driver");
1 120000000890000
Connection connection = DriverManager . getConnection("jdbc :mysql://localhost:3306_ user", "root","");1/300yAsq1900
String sql = "SELECT userNAME , gender FROM t
user";
1140000391
PreparedStatement prepareStatement = connection. prepareStatement(sql);
1/50000sq1
ResultSet rs=prepareStatement . executeQuery();
ResultSet rs=prepareStatement . executeQuery();
while(rs.next() )f
System. out. println(rs. getObject( "userNAME"));
System. out . println(rs. get0bject("gender"));
prepareStatement. close();
connection. close( );
查询语句:四个不同:SQL语句不同、调用语句不同、返回类型不同、返回值不同
拼写SQL:String sql ="SELECT userNAME.gendenr FROM t_user";
执行SQL:ResultSet rs=prepaareStatement.executeQuery();
处理结果:while(rs.next()){
system out.println(rs.getobject("userName"));
system out.println(rs.getobject("gender"));

个人心得:通过今天的学习,我学会了很多东西,也有很多不懂的地方,老师悉心指导,也经过自己的努力,终于成功安装完成,下午又降了关于数据库的一些知识,受益匪浅

标签

评论

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