首页 > 其他分享 >超级课表实验感想

超级课表实验感想

时间:2022-10-14 09:00:24浏览次数:45  
标签:return String 超级 感想 private public 课表 xingqi void

1.超级课程表查询:

(1)按照图中样式完成web界面设计;

 

 

 

 (2)将上课课表信息导入数据库。(可以在数据库管理端手动添加);

(3)输入课程名称、任课教师、上课地点任一一项内容,点击查询按钮,都可显示出课程的详细信息。

 

 

 源码:IN.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>课程查询</title>
</head>
<body>
<form action="jianmin1.jsp" method="get">
<table align="center" border="1" width="500">

<tr>
<td>课程名:</td>
<td><input type="text" name="kechengming" /></td>
</tr>
<tr>
<td>教师名:</td>
<td><input type="text" name="jiaoshiming" /></td>
</tr>
<tr>
<td>教室:</td>
<td><input type="text" name="jiaoshi" /></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" value="提交" /></td>
</tr>
</table>
</form>
</body>
</html>

UserDao.java

package entity;

public class Classs {
private String kechengming;
private String jiaoshiming;
private String jiaoshi;
private String jieci;
private String xingqi;
public String getKechengming() {
return kechengming;
}
public String getJiaoshiming() {
return jiaoshiming;
}
public String getJiaoshi() {
return jiaoshi;
}
public String getJieci() {
return jieci;
}
public String getXingqi() {
return xingqi;
}
public void setKechengming(String kechengming) {
this.kechengming = kechengming;
}
public void setJiaoshiming(String jiaoshiming) {
this.jiaoshiming = jiaoshiming;
}
public void setJiaoshi(String jiaoshi) {
this.jiaoshi = jiaoshi;
}
public void setJieci(String jieci) {
this.jieci = jieci;
}
public void setXingqi(String xingqi) {
this.xingqi = xingqi;
}

}

 DBUtil .java

package dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBUtil {

public static Connection getConnection() {
try {
// 1 加载驱动
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String name = "root";
String password = "123\\";
String url = "jdbc:mysql://localhost:3306/class";
Connection connection = null;
try {
// 2 创建链接对象connection
connection = DriverManager.getConnection(url, name, password);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return connection;
}

// 关闭资源的方法
public static void close(Connection connection) {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public static void close(PreparedStatement preparedStatement) {
try {
if (preparedStatement != null) {
preparedStatement.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public static void close(ResultSet resultSet) {
try {
if (resultSet != null) {
resultSet.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

Class.java

package entity;

public class Classs {
private String kechengming;
private String jiaoshiming;
private String jiaoshi;
private String jieci;
private String xingqi;
public String getKechengming() {
return kechengming;
}
public String getJiaoshiming() {
return jiaoshiming;
}
public String getJiaoshi() {
return jiaoshi;
}
public String getJieci() {
return jieci;
}
public String getXingqi() {
return xingqi;
}
public void setKechengming(String kechengming) {
this.kechengming = kechengming;
}
public void setJiaoshiming(String jiaoshiming) {
this.jiaoshiming = jiaoshiming;
}
public void setJiaoshi(String jiaoshi) {
this.jiaoshi = jiaoshi;
}
public void setJieci(String jieci) {
this.jieci = jieci;
}
public void setXingqi(String xingqi) {
this.xingqi = xingqi;
}

}

结果:

 

 

        

 

 

 

 

感想:这次老师交给我们的任务明显感觉 到比以往更加困难了,让我们用mysql来链接数据库,并且要下载Tomcat建表,用Tomcat6作服务器测试确实会遇到很多问题,因为windows用习惯了,总希望能自动生成所谓重要的WEB-INF和WETA-INF文件夹中的所有内容,用myeclipse确实可以搞定,到这里我已经感觉,java功能确实强大,艰辛的做完这次作业,感觉确实与平时不一样。

 

标签:return,String,超级,感想,private,public,课表,xingqi,void
From: https://www.cnblogs.com/yunbianshangdadun/p/16790470.html

相关文章