展开全部
Java WEB编程tomcat验证连接数据库mysql测试:62616964757a686964616fe4b893e5b19e31333337613131
1、将mysql的jdbc驱动程序放到tomcat的lib中:mysql_connect_jdbcdriver.jar
test1.jsp中内容如下:
My JSP starting pagetry {
//加载驱动
Class.forName("com.mysql.jdbc.Driver");
//建立连接
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","root","mysql");
//创建状态
Statement state=con.createStatement();
//插入
String sql="insert into student values('Gosling','java'),('002','zxy')";
state.executeUpdate(sql);
//更新
String sql1="update student set stuID='001' where stuName='java'";
state.executeUpdate(sql1);
//修改
String sql3="update student set stuName=