Skip to content

Commit a2c4e1f

Browse files
committed
submit
1 parent 683e43e commit a2c4e1f

7 files changed

Lines changed: 119 additions & 16 deletions

File tree

HtmlBootStrap/HtmlBootStrap.iml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module type="JAVA_MODULE" version="4">
2+
<module type="WEB_MODULE" version="4">
33
<component name="NewModuleRootManager" inherit-compiler-output="true">
44
<exclude-output />
5-
<content url="file://$MODULE_DIR$">
6-
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7-
</content>
5+
<content url="file://$MODULE_DIR$" />
86
<orderEntry type="inheritedJdk" />
97
<orderEntry type="sourceFolder" forTests="false" />
108
</component>

JavaWeb/Test.iml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="web" name="Web">
5+
<configuration>
6+
<descriptors>
7+
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
8+
</descriptors>
9+
<webroots>
10+
<root url="file://$MODULE_DIR$/web" relative="/" />
11+
</webroots>
12+
</configuration>
13+
</facet>
14+
</component>
15+
<component name="NewModuleRootManager" inherit-compiler-output="true">
16+
<exclude-output />
17+
<content url="file://$MODULE_DIR$">
18+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
19+
</content>
20+
<orderEntry type="inheritedJdk" />
21+
<orderEntry type="sourceFolder" forTests="false" />
22+
</component>
23+
</module>

JavaWeb/src/getlist.http

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# For a quick start check out our HTTP Requests collection (Tools|HTTP Client|Open HTTP Requests Collection).
2+
#
3+
# Following HTTP Request Live Templates are available:
4+
# * 'gtrp' and 'gtr' create a GET request with or without query parameters;
5+
# * 'ptr' and 'ptrp' create a POST request with a simple or parameter-like body;
6+
# * 'mptr' and 'fptr' create a POST request to submit a form with a text or file field (multipart/form-data);

JavaWeb/web/WEB-INF/web.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
5+
version="4.0">
6+
</web-app>

Mysql/src/com/study/entity/Student.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ public class Student {
88
private String name;
99
private int age;
1010
private Date date;
11-
private BigDecimal amoutn;
12-
11+
private double amount;
12+
private int id ;
1313
public int getId() {
1414
return id;
1515
}
@@ -18,7 +18,7 @@ public void setId(int id) {
1818
this.id = id;
1919
}
2020

21-
private int id ;
21+
2222
public String getName() {
2323
return name;
2424
}
@@ -43,23 +43,23 @@ public void setDate(Date date) {
4343
this.date = date;
4444
}
4545

46-
public BigDecimal getAmoutn() {
47-
return amoutn;
46+
public double getAmount() {
47+
return amount;
4848
}
4949

50-
public void setAmoutn(BigDecimal amoutn) {
51-
this.amoutn = amoutn;
50+
public void setAmount(double amount) {
51+
this.amount = amount;
5252
}
5353

54-
/* @Override
54+
@Override
5555
public String toString() {
5656
return "Student{" +
5757
"name='" + name + '\'' +
5858
", age=" + age +
5959
", date=" + date +
60-
", amoutn=" + amoutn +
60+
", amount=" + amount +
6161
", id=" + id +
62-
'}';
63-
}*/
62+
'}'+"\n";
63+
}
6464
}
6565

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.study.templatetest;
2+
3+
import com.study.entity.Student;
4+
import com.study.until.JDBCUntil;
5+
import com.study.until.JDBCUntilsForJDBCTempLate;
6+
import org.junit.Test;
7+
import org.springframework.jdbc.core.BeanPropertyRowMapper;
8+
import org.springframework.jdbc.core.JdbcTemplate;
9+
import org.springframework.jdbc.core.RowMapper;
10+
import org.springframework.transaction.annotation.Transactional;
11+
12+
import java.sql.Connection;
13+
import java.sql.PreparedStatement;
14+
import java.sql.ResultSet;
15+
import java.sql.SQLException;
16+
import java.util.List;
17+
import java.util.Map;
18+
19+
public class TemplateDemo {
20+
21+
private JdbcTemplate jdbcTemplate = new JdbcTemplate(JDBCUntilsForJDBCTempLate.dataSource);
22+
23+
24+
@Test
25+
public void TestQuery() {
26+
27+
RowMapper<Student> rowMapper = new RowMapper<Student>() {
28+
@Override
29+
public Student mapRow(ResultSet resultSet, int i) throws SQLException {
30+
Student student = new Student();
31+
student.setName(resultSet.getString("name"));
32+
student.setId(resultSet.getInt("id"));
33+
return student;
34+
}
35+
};
36+
List<Student> query = jdbcTemplate.query("select * from student", rowMapper);
37+
System.out.println(query);
38+
}
39+
40+
@Test
41+
public void TestTran() {
42+
Connection connection = null;
43+
try {
44+
//jdbctemplate 想要事务的还是要获取原来的connection不知道是否有其他的办法
45+
connection = jdbcTemplate.getDataSource().getConnection();
46+
connection.setAutoCommit(false);
47+
PreparedStatement preparedStatement = connection.prepareStatement("update student set name='tranException' where id=?");
48+
preparedStatement.setInt(1, 1);
49+
PreparedStatement preparedStatement1 = connection.prepareStatement("update student set name ='tranException1' where id=?");
50+
preparedStatement1.setInt(1, 2);
51+
preparedStatement.executeUpdate();
52+
int i = 1 / 0;
53+
preparedStatement1.executeUpdate();
54+
connection.commit();
55+
} catch (SQLException e) {
56+
e.printStackTrace();
57+
}
58+
59+
60+
}
61+
62+
@Test
63+
public void queryss() {
64+
65+
//getName 写错了 其实就相当于C#中的属性错了 反射 找到当前字段的 getset方法 然后执行这个方法 因为写错了 找不到
66+
// 所以.......就有问题了
67+
List<Student> query = jdbcTemplate.query("select * from student where id=1", new BeanPropertyRowMapper<Student>(Student.class));
68+
System.out.println(query);
69+
}
70+
}

Mysql/src/com/study/test/MysqlCRUDTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void Query() {
4747
s.setName(result.getString("name"));
4848
s.setAge(result.getInt("age"));
4949
s.setDate(result.getTimestamp("date"));
50-
s.setAmoutn(result.getBigDecimal("amount"));
50+
//s.setAmoutn(result.getBigDecimal("amount"));
5151
s.setId(result.getInt("id"));
5252
students.add(s);
5353

0 commit comments

Comments
 (0)