xerga 1 year ago
parent
commit
3c3a1cdd2e
100 changed files with 3129 additions and 0 deletions
  1. 38 0
      JDBC/.gitignore
  2. 8 0
      JDBC/.idea/.gitignore
  3. 12 0
      JDBC/.idea/dataSources.xml
  4. 7 0
      JDBC/.idea/encodings.xml
  5. 14 0
      JDBC/.idea/misc.xml
  6. 124 0
      JDBC/.idea/uiDesigner.xml
  7. 6 0
      JDBC/.idea/vcs.xml
  8. 53 0
      JDBC/pom.xml
  9. 23 0
      JDBC/src/main/java/com/lc/jdbc/TestJdbc.java
  10. 47 0
      JDBC/src/main/java/com/lc/jdbc/TestJdbc1.java
  11. 52 0
      JDBC/src/main/java/com/lc/jdbc/TestJdbc2.java
  12. 63 0
      JDBC/src/main/java/com/lc/jdbc/TestJdbc3.java
  13. 76 0
      JDBC/src/main/java/com/lc/jdbc/TestJdbc4.java
  14. 92 0
      JDBC/src/main/java/com/lc/jdbc1/Emp.java
  15. 128 0
      JDBC/src/main/java/com/lc/jdbc1/EmpDao.java
  16. 86 0
      JDBC/src/main/java/com/lc/jdbc1/Test01.java
  17. 92 0
      JDBC/src/main/java/com/lc/jdbc2/Emp.java
  18. 52 0
      JDBC/src/main/java/com/lc/jdbc2/EmpDao.java
  19. 48 0
      JDBC/src/main/java/com/lc/jdbc2/Test01.java
  20. 23 0
      JDBC/src/main/java/com/lc/jdbc3/Column.java
  21. 24 0
      JDBC/src/main/java/com/lc/jdbc3/Table.java
  22. 82 0
      JDBC/src/main/java/com/lc/jdbc3/Test01.java
  23. 76 0
      JDBC/src/main/java/com/lc/jdbc3/User.java
  24. 23 0
      JDBC/src/main/java/com/lc/jdbc4/Column.java
  25. 85 0
      JDBC/src/main/java/com/lc/jdbc4/Emp.java
  26. 13 0
      JDBC/src/main/java/com/lc/jdbc4/EmpDao.java
  27. 22 0
      JDBC/src/main/java/com/lc/jdbc4/Table.java
  28. 47 0
      JDBC/src/main/java/com/lc/jdbc4/Test01.java
  29. 77 0
      JDBC/src/main/java/com/lc/jdbc4/User.java
  30. 14 0
      JDBC/src/main/java/com/lc/jdbc4/UserDao.java
  31. 23 0
      JDBC/src/main/java/com/lc/jdbc5/Column.java
  32. 14 0
      JDBC/src/main/java/com/lc/jdbc5/EmpDao.java
  33. 39 0
      JDBC/src/main/java/com/lc/jdbc5/Person.java
  34. 14 0
      JDBC/src/main/java/com/lc/jdbc5/PersonDao.java
  35. 21 0
      JDBC/src/main/java/com/lc/jdbc5/Table.java
  36. 62 0
      JDBC/src/main/java/com/lc/jdbc5/Test01.java
  37. BIN
      JDBC/src/main/java/com/lc/lc.zip
  38. 224 0
      JDBC/src/main/java/com/lc/utils/BaseDAO.java
  39. 56 0
      JDBC/src/main/java/com/lc/utils/DButils.java
  40. 10 0
      JDBC/src/main/resources/jdbc.properties
  41. 16 0
      JavaSE/.idea/compiler.xml
  42. 20 0
      JavaSE/.idea/jarRepositories.xml
  43. 16 0
      JavaSE/day04/pom.xml
  44. 55 0
      JavaSE/day04/src/main/java/com/sf/Day04.java
  45. 12 0
      JavaSE/day04/src/main/java/com/sf/Test1.java
  46. 41 0
      JavaSE/day04/src/main/java/com/sf/Test2.java
  47. 26 0
      JavaSE/day04/src/main/java/com/sf/Test3.java
  48. 21 0
      JavaSE/day04/src/main/java/com/sf/Test4.java
  49. 41 0
      JavaSE/day04/src/main/java/com/sf/Test5.java
  50. 21 0
      JavaSE/day04/src/main/java/com/sf/Test6.java
  51. 16 0
      JavaSE/day05/pom.xml
  52. 33 0
      JavaSE/day05/src/main/java/com/sf/BinFind.java
  53. 100 0
      JavaSE/day05/src/main/java/com/sf/Test1.java
  54. 89 0
      JavaSE/day05/src/main/java/com/sf/Test19BubbleSort.java
  55. 34 0
      JavaSE/day05/src/main/java/com/sf/Test19BubbleSort2.java
  56. 88 0
      JavaSE/day05/src/main/java/com/sf/Test2.java
  57. 46 0
      JavaSE/day05/src/main/java/com/sf/Test3.java
  58. 26 0
      JavaSE/day05/src/main/java/com/sf/TestArrayOrderSearch.java
  59. 38 0
      JavaSE/day05/src/main/java/com/sf/TestArrayReverse1.java
  60. 25 0
      JavaSE/day05/src/main/java/com/sf/TestArrayReverse2.java
  61. BIN
      JavaSE/day05/target/classes/com/sf/BinFind.class
  62. BIN
      JavaSE/day05/target/classes/com/sf/Test1.class
  63. BIN
      JavaSE/day05/target/classes/com/sf/Test19BubbleSort.class
  64. BIN
      JavaSE/day05/target/classes/com/sf/Test19BubbleSort2.class
  65. BIN
      JavaSE/day05/target/classes/com/sf/Test2.class
  66. BIN
      JavaSE/day05/target/classes/com/sf/Test3.class
  67. BIN
      JavaSE/day05/target/classes/com/sf/TestArrayOrderSearch.class
  68. BIN
      JavaSE/day05/target/classes/com/sf/TestArrayReverse1.class
  69. BIN
      JavaSE/day05/target/classes/com/sf/TestArrayReverse2.class
  70. BIN
      JavaSE/day05/target/classes/com/sf/TestYear.class
  71. BIN
      JavaSE/day05/target/classes/com/sf/YEARTest.class
  72. 16 0
      JavaSE/day06/pom.xml
  73. 18 0
      JavaSE/day06/src/main/java/com/sf/City.java
  74. 13 0
      JavaSE/day06/src/main/java/com/sf/Country.java
  75. 17 0
      JavaSE/day06/src/main/java/com/sf/Huashan.java
  76. 12 0
      JavaSE/day06/src/main/java/com/sf/Jianzong.java
  77. 31 0
      JavaSE/day06/src/main/java/com/sf/Person.java
  78. 11 0
      JavaSE/day06/src/main/java/com/sf/Qizong.java
  79. 35 0
      JavaSE/day06/src/main/java/com/sf/Student.java
  80. 12 0
      JavaSE/day06/src/main/java/com/sf/Test.java
  81. 16 0
      JavaSE/day06/src/main/java/com/sf/codeBlock/Father.java
  82. 16 0
      JavaSE/day06/src/main/java/com/sf/codeBlock/Son.java
  83. 20 0
      JavaSE/day06/src/main/java/com/sf/codeBlock/Test1.java
  84. 18 0
      JavaSE/day06/src/main/java/com/sf/codeBlock/Test2.java
  85. 29 0
      JavaSE/day06/src/main/java/com/sf/codeBlock/Test3.java
  86. 7 0
      JavaSE/day06/src/main/java/com/sf/codeBlock/TestSonCode.java
  87. 20 0
      JavaSE/day06/src/main/java/com/sf/final1/A.java
  88. 12 0
      JavaSE/day06/src/main/java/com/sf/final1/B.java
  89. 21 0
      JavaSE/day06/src/main/java/com/sf/static2/Person.java
  90. 39 0
      JavaSE/day06/src/main/java/com/sf/static2/Student.java
  91. 8 0
      JavaSE/day06/src/main/java/com/sf/static2/Student2.java
  92. 9 0
      JavaSE/day06/src/main/java/com/sf/static2/TestStatic.java
  93. 15 0
      JavaSE/day06/src/main/java/com/sf/static2/TestStaticMethod.java
  94. BIN
      JavaSE/day06/target/classes/com/sf/City.class
  95. BIN
      JavaSE/day06/target/classes/com/sf/Country.class
  96. BIN
      JavaSE/day06/target/classes/com/sf/Huashan.class
  97. BIN
      JavaSE/day06/target/classes/com/sf/Jianzong.class
  98. BIN
      JavaSE/day06/target/classes/com/sf/Person.class
  99. BIN
      JavaSE/day06/target/classes/com/sf/Qizong.class
  100. BIN
      JavaSE/day06/target/classes/com/sf/Student.class

+ 38 - 0
JDBC/.gitignore

@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store

+ 8 - 0
JDBC/.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 12 - 0
JDBC/.idea/dataSources.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="DataSourceManagerImpl" format="xml" multifile-model="true">
+    <data-source source="LOCAL" name="@localhost" uuid="1118f294-3737-4025-823f-a304445b31ed">
+      <driver-ref>mysql.8</driver-ref>
+      <synchronize>true</synchronize>
+      <jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
+      <jdbc-url>jdbc:mysql://localhost:3306</jdbc-url>
+      <working-dir>$ProjectFileDir$</working-dir>
+    </data-source>
+  </component>
+</project>

+ 7 - 0
JDBC/.idea/encodings.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding">
+    <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
+  </component>
+</project>

+ 14 - 0
JDBC/.idea/misc.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ExternalStorageConfigurationManager" enabled="true" />
+  <component name="MavenProjectsManager">
+    <option name="originalFiles">
+      <list>
+        <option value="$PROJECT_DIR$/pom.xml" />
+      </list>
+    </option>
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>

+ 124 - 0
JDBC/.idea/uiDesigner.xml

@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Palette2">
+    <group name="Swing">
+      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
+      </item>
+      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
+        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
+        <initial-values>
+          <property name="text" value="Button" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="RadioButton" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="CheckBox" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="Label" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
+          <preferred-size width="-1" height="20" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
+      </item>
+    </group>
+  </component>
+</project>

+ 6 - 0
JDBC/.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
+  </component>
+</project>

+ 53 - 0
JDBC/pom.xml

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.example</groupId>
+    <artifactId>JDBC</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <maven.compiler.source>17</maven.compiler.source>
+        <maven.compiler.target>17</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <!-- 依赖 -->
+    <dependencies>
+        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>8.0.28</version>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.2.8</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.13.1</version>
+            <scope>compile</scope>
+        </dependency>
+
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>17</source>
+                    <target>17</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 23 - 0
JDBC/src/main/java/com/lc/jdbc/TestJdbc.java

@@ -0,0 +1,23 @@
+package com.lc.jdbc;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+/**
+ * ClassName: TestJdbc
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/25 10:27
+ * @Version 1.0
+ */
+public class TestJdbc {
+
+    public static void main(String[] args) throws SQLException {
+        System.out.println("Hello World!");
+
+        //第三方
+        Connection connection = DriverManager.getConnection("1", "1", "1");
+
+    }
+}

+ 47 - 0
JDBC/src/main/java/com/lc/jdbc/TestJdbc1.java

@@ -0,0 +1,47 @@
+package com.lc.jdbc;
+
+import org.junit.Test;
+
+import java.sql.*;
+
+/**
+ * ClassName: TestJdbc
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/25 10:27
+ * @Version 1.0
+ */
+public class TestJdbc1 {
+
+     @Test
+     public void test01() throws Exception {
+         //加载驱动
+         Class.forName("com.mysql.cj.jdbc.Driver");
+         //建立连接
+         String user = "root";
+         String pass = "123456";
+         String url = "jdbc:mysql://127.0.0.1:3306/db2?useSSL=false";
+         //连接
+         Connection connection = DriverManager.getConnection(url, user, pass);
+         //sql执行对象
+         Statement statement = connection.createStatement();
+         //sql
+         String sql = " select * from emp ";
+         // 执行获取结果
+         ResultSet resultSet = statement.executeQuery(sql);
+         // 遍历
+         while (resultSet.next()){
+             String id = resultSet.getString("id");
+             String ename = resultSet.getString("ename");
+             String sal = resultSet.getString("salary");
+
+             System.out.println("id:"+id+"name:"+ename+"sal:"+sal);
+         }
+
+         //关闭
+         resultSet.close();
+         statement.close();
+         connection.close();
+
+     }
+}

+ 52 - 0
JDBC/src/main/java/com/lc/jdbc/TestJdbc2.java

@@ -0,0 +1,52 @@
+package com.lc.jdbc;
+
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+/**
+ * ClassName: TestJdbc
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/25 10:27
+ * @Version 1.0
+ */
+public class TestJdbc2 {
+
+     @Test
+     public void test01() throws Exception {
+         //加载驱动
+         Class.forName("com.mysql.cj.jdbc.Driver");
+         //建立连接
+         String user = "root";
+         String pass = "123456";
+         String url = "jdbc:mysql://127.0.0.1:3306/db2?useSSL=false";
+         //连接
+         Connection connection = DriverManager.getConnection(url, user, pass);
+
+         //sql预编译执行对象。
+         //connection.prepareStatement()
+
+         //开启事务
+         //connection.setAutoCommit(false);
+         //提交
+         //connection.commit();
+         //回滚
+         //connection.rollback();
+
+         Statement statement = connection.createStatement();
+
+
+         ResultSet resultSet = statement.executeQuery("");
+
+
+         boolean next = resultSet.next();
+
+
+
+
+     }
+}

+ 63 - 0
JDBC/src/main/java/com/lc/jdbc/TestJdbc3.java

@@ -0,0 +1,63 @@
+package com.lc.jdbc;
+
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+/**
+ * ClassName: TestJdbc
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/25 10:27
+ * @Version 1.0
+ */
+public class TestJdbc3 {
+
+     @Test
+     public void test01() throws Exception {
+         //加载驱动
+         Class.forName("com.mysql.cj.jdbc.Driver");
+         //建立连接
+         String user = "root";
+         String pass = "123456";
+         String url = "jdbc:mysql://127.0.0.1:3306/db2?useSSL=false";
+         //连接
+         Connection connection = DriverManager.getConnection(url, user, pass);
+         // 事务
+         connection.setAutoCommit(false);
+         Statement statement = connection.createStatement();
+         //案例
+         // 悟空 给 卢俊义  转  1000.
+
+         try {
+             // 给悟空  - 1000
+             String sql1 = " update emp set salary = salary - 1000 WHERE id = 1001; ";
+             statement.execute(sql1);
+
+             // 异常
+             int i = 1 / 0;
+
+             //  俊义   + 1000
+             String sql2 = " update emp set salary = salary + 1000 WHERE id = 1002; ";
+             statement.execute(sql2);
+
+             //执行成功
+             connection.commit();
+             //转账成功
+             System.out.println("转账成功");
+         } catch (Exception e) {
+             e.printStackTrace();
+             //回滚
+             connection.rollback();
+             //转账失败
+             System.out.println("转账失败");
+         }
+         //释放
+         statement.close();
+         connection.close();
+
+     }
+}

+ 76 - 0
JDBC/src/main/java/com/lc/jdbc/TestJdbc4.java

@@ -0,0 +1,76 @@
+package com.lc.jdbc;
+
+import org.junit.Test;
+
+import java.sql.*;
+import java.util.Collections;
+
+/**
+ * ClassName: TestJdbc
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/25 10:27
+ * @Version 1.0
+ */
+public class TestJdbc4 {
+
+     @Test
+     public void test01() throws Exception {
+         //加载驱动
+         Class.forName("com.mysql.cj.jdbc.Driver");
+         //建立连接
+         String user = "root";
+         String pass = "123456";
+         String url = "jdbc:mysql://127.0.0.1:3306/db2?useSSL=false";
+         //连接
+         Connection connection = DriverManager.getConnection(url, user, pass);
+
+         //转账
+         transfer("abc","1002",100,connection);
+
+         //释放
+         connection.close();
+
+     }
+
+
+     //转账方法
+    public  boolean transfer(String fromId, String toId, int money , Connection conn) throws SQLException {
+        // 事务
+        conn.setAutoCommit(false);
+        //改变 sql执行对象 PreparedStatement 变为字符串
+        try {
+            String sql1 = " update emp set salary = salary - ? WHERE id = ? ; ";
+            //预编译
+            PreparedStatement preparedStatement1 = conn.prepareStatement(sql1);
+            //设置参数
+            preparedStatement1.setInt(1,money);
+            preparedStatement1.setString(2,fromId);
+            //执行
+            preparedStatement1.execute();
+            //声明sql
+            //参数 使用 ?
+            String sql2 = " update emp set salary = salary + ? WHERE id = ? ; ";
+            PreparedStatement preparedStatement2 = conn.prepareStatement(sql1);
+
+            //设置参数  第一个参数是索引 从1开始 第几个?  第二个参数是值。
+            //setXxx 类型
+            preparedStatement2.setInt(1,money);
+            preparedStatement2.setString(2,toId);
+            //执行
+            preparedStatement2.execute();
+            //提交
+            conn.commit();
+            //转账成功
+            System.out.println("转账成功");
+            return true;
+        } catch (SQLException ex) {
+            ex.printStackTrace();
+            //回滚
+            conn.rollback();
+            //转账失败
+            System.out.println("转账失败");
+            return false;
+        }
+    };
+}

+ 92 - 0
JDBC/src/main/java/com/lc/jdbc1/Emp.java

@@ -0,0 +1,92 @@
+package com.lc.jdbc1;
+
+import java.util.Date;
+
+/**
+ * ClassName: Emp
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/25 15:50
+ * @Version 1.0
+ */
+public class Emp {
+    private Integer id;
+    private String ename;
+    private Integer mgr;
+    private Date joindate;
+    private Integer salary;
+    private Integer bonus;
+
+
+    public Emp() {
+    }
+
+    public Emp(Integer id, String ename, Integer mgr, Date joindate, Integer salary, Integer bonus) {
+        this.id = id;
+        this.ename = ename;
+        this.mgr = mgr;
+        this.joindate = joindate;
+        this.salary = salary;
+        this.bonus = bonus;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getEname() {
+        return ename;
+    }
+
+    public void setEname(String ename) {
+        this.ename = ename;
+    }
+
+    public Integer getMgr() {
+        return mgr;
+    }
+
+    public void setMgr(Integer mgr) {
+        this.mgr = mgr;
+    }
+
+    public Date getJoindate() {
+        return joindate;
+    }
+
+    public void setJoindate(Date joindate) {
+        this.joindate = joindate;
+    }
+
+    public Integer getSalary() {
+        return salary;
+    }
+
+    public void setSalary(Integer salary) {
+        this.salary = salary;
+    }
+
+    public Integer getBonus() {
+        return bonus;
+    }
+
+    public void setBonus(Integer bonus) {
+        this.bonus = bonus;
+    }
+
+    @Override
+    public String toString() {
+        return "Emp{" +
+                "id=" + id +
+                ", ename='" + ename + '\'' +
+                ", mgr='" + mgr + '\'' +
+                ", joindate=" + joindate +
+                ", salary=" + salary +
+                ", bonus=" + bonus +
+                '}';
+    }
+}

+ 128 - 0
JDBC/src/main/java/com/lc/jdbc1/EmpDao.java

@@ -0,0 +1,128 @@
+package com.lc.jdbc1;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * ClassName: EmpDao
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/25 15:54
+ * @Version 1.0
+ */
+public class EmpDao {
+    static Connection connection = null;
+    static  {
+        //建立连接
+        String user = "root";
+        String pass = "123456";
+        String url = "jdbc:mysql://127.0.0.1:3306/db2?useSSL=false";
+        //连接
+        try {
+            connection = DriverManager.getConnection(url, user, pass);
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+
+    public List<Emp> getAll() throws Exception{
+
+        String sql = " select * from emp ";
+        //预编译
+        PreparedStatement statement = connection.prepareStatement(sql);
+
+        ResultSet resultSet = statement.executeQuery();
+
+        List<Emp> list = new ArrayList<>();
+        while(resultSet.next()){
+            Emp emp = new Emp();
+            emp.setId(resultSet.getInt("id"));
+            emp.setEname(resultSet.getString("ename"));
+            emp.setJoindate(resultSet.getDate("joindate"));
+            emp.setMgr(resultSet.getInt("mgr"));
+            emp.setBonus(resultSet.getInt("bonus"));
+            list.add(emp);
+        }
+        return list;
+    }
+
+    public Emp get(Integer id) throws Exception{
+
+        String sql = " select * from emp where id = ? ";
+        //预编译
+        PreparedStatement statement = connection.prepareStatement(sql);
+        //设置参数
+        statement.setInt(1, id);
+
+        ResultSet resultSet = statement.executeQuery();
+
+        Emp emp = new Emp();
+        while(resultSet.next()){
+            emp.setId(resultSet.getInt("id"));
+            emp.setEname(resultSet.getString("ename"));
+            emp.setJoindate(resultSet.getDate("joindate"));
+            emp.setMgr(resultSet.getInt("mgr"));
+            emp.setBonus(resultSet.getInt("bonus"));
+        }
+        return emp;
+    }
+
+
+
+    public boolean del(Integer id) throws Exception{
+
+        String sql = "  delete from emp where id = ? ";
+        //预编译
+        PreparedStatement statement = connection.prepareStatement(sql);
+        //设置参数
+        statement.setInt(1, id);
+
+        //执行 返回的是受影响记录数
+        return statement.executeUpdate() > 0;
+    }
+
+
+    public boolean add(Emp emp) throws Exception{
+
+        String sql = " INSERT INTO `db2`.`emp` " +
+                "( `ename`, `mgr`, `joindate`, `salary`, `bonus`,`id`) " +
+                "VALUES (?,?,?,?,?,?); ";
+        //预编译
+        PreparedStatement statement = connection.prepareStatement(sql);
+        //设置参数
+        statement.setString(1, emp.getEname());
+        statement.setInt(2, emp.getMgr());
+        //sql时间
+        Date date = new Date();
+        statement.setDate(3, new java.sql.Date(date.getTime()));
+        statement.setInt(4, emp.getSalary());
+        statement.setInt(5, emp.getBonus());
+        statement.setInt(6, emp.getId());
+
+        return statement.execute();
+    }
+
+    public boolean update(Emp emp) throws Exception{
+
+        String sql = " UPDATE `db2`.`emp` " +
+                "SET `ename` = ?,  `mgr` = ?, `joindate` = ?, `salary` = ?, `bonus` = ?  WHERE `id` = ? ";
+        //预编译
+        PreparedStatement statement = connection.prepareStatement(sql);
+        //设置参数
+        statement.setString(1, emp.getEname());
+        statement.setInt(2, emp.getMgr());
+        //sql时间
+        Date date = new Date();
+        statement.setDate(3, new java.sql.Date(date.getTime()));
+        statement.setInt(4, emp.getSalary());
+        statement.setInt(5, emp.getBonus());
+        statement.setInt(6, emp.getId());
+
+        //执行 返回的是受影响记录数
+        return statement.executeUpdate() > 0;
+    }
+
+}

+ 86 - 0
JDBC/src/main/java/com/lc/jdbc1/Test01.java

@@ -0,0 +1,86 @@
+package com.lc.jdbc1;
+
+import org.junit.Test;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * ClassName: Test01
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/25 16:01
+ * @Version 1.0
+ */
+public class Test01 {
+
+    @Test
+    public void test05() throws Exception {
+        EmpDao empDao = new EmpDao();
+        List<Emp> all = empDao.getAll();
+        all.forEach(System.out::println);
+    }
+
+    @Test
+    public void test04() throws Exception {
+        EmpDao empDao = new EmpDao();
+        Emp emp = empDao.get(1);
+        System.out.println(emp);
+    }
+
+    @Test
+    public void test03() throws Exception {
+        EmpDao empDao = new EmpDao();
+        boolean del = empDao.del(1001);
+        if (del){
+            System.out.println("成功");
+        }else {
+            System.out.println("失败");
+        }
+    }
+
+
+    @Test
+    public void test02() throws Exception {
+        EmpDao empDao = new EmpDao();
+
+        Emp emp = new Emp();
+        emp.setId(1002);
+        emp.setEname("fanfan");
+        emp.setMgr(1);
+        emp.setJoindate(new Date());
+        emp.setSalary(12000);
+        emp.setBonus(100);
+
+        boolean add = empDao.update(emp);
+        if (add){
+            System.out.println("成功");
+        }else {
+            System.out.println("失败");
+        }
+    }
+
+
+    @Test
+    public void test01() throws Exception {
+        EmpDao empDao = new EmpDao();
+
+        Emp emp = new Emp();
+        emp.setId(1);
+        emp.setEname("kunkun");
+        emp.setMgr(0);
+        emp.setJoindate(new Date());
+        emp.setSalary(10000);
+        emp.setBonus(1000);
+
+        boolean add = empDao.add(emp);
+        if (add){
+            System.out.println("成功");
+        }else {
+            System.out.println("失败");
+        }
+    }
+
+
+
+}

+ 92 - 0
JDBC/src/main/java/com/lc/jdbc2/Emp.java

@@ -0,0 +1,92 @@
+package com.lc.jdbc2;
+
+import java.util.Date;
+
+/**
+ * ClassName: Emp
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/25 15:50
+ * @Version 1.0
+ */
+public class Emp {
+    private Integer id;
+    private String ename;
+    private Integer mgr;
+    private Date joindate;
+    private Integer salary;
+    private Integer bonus;
+
+
+    public Emp() {
+    }
+
+    public Emp(Integer id, String ename, Integer mgr, Date joindate, Integer salary, Integer bonus) {
+        this.id = id;
+        this.ename = ename;
+        this.mgr = mgr;
+        this.joindate = joindate;
+        this.salary = salary;
+        this.bonus = bonus;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getEname() {
+        return ename;
+    }
+
+    public void setEname(String ename) {
+        this.ename = ename;
+    }
+
+    public Integer getMgr() {
+        return mgr;
+    }
+
+    public void setMgr(Integer mgr) {
+        this.mgr = mgr;
+    }
+
+    public Date getJoindate() {
+        return joindate;
+    }
+
+    public void setJoindate(Date joindate) {
+        this.joindate = joindate;
+    }
+
+    public Integer getSalary() {
+        return salary;
+    }
+
+    public void setSalary(Integer salary) {
+        this.salary = salary;
+    }
+
+    public Integer getBonus() {
+        return bonus;
+    }
+
+    public void setBonus(Integer bonus) {
+        this.bonus = bonus;
+    }
+
+    @Override
+    public String toString() {
+        return "Emp{" +
+                "id=" + id +
+                ", ename='" + ename + '\'' +
+                ", mgr='" + mgr + '\'' +
+                ", joindate=" + joindate +
+                ", salary=" + salary +
+                ", bonus=" + bonus +
+                '}';
+    }
+}

+ 52 - 0
JDBC/src/main/java/com/lc/jdbc2/EmpDao.java

@@ -0,0 +1,52 @@
+package com.lc.jdbc2;
+
+import com.lc.utils.DButils;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * ClassName: EmpDao
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/25 15:54
+ * @Version 1.0
+ */
+public class EmpDao {
+    static Connection connection = null;
+    //获取连接
+    static {
+        //获取连接
+        try {
+            connection  = DButils.getConnection();
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public List<Emp> getAll() throws Exception{
+
+
+        String sql = " select * from emp ";
+        //预编译
+        PreparedStatement statement = connection.prepareStatement(sql);
+
+        ResultSet resultSet = statement.executeQuery();
+
+        List<Emp> list = new ArrayList<>();
+        while(resultSet.next()){
+            Emp emp = new Emp();
+            emp.setId(resultSet.getInt("id"));
+            emp.setEname(resultSet.getString("ename"));
+            emp.setJoindate(resultSet.getDate("joindate"));
+            emp.setMgr(resultSet.getInt("mgr"));
+            emp.setBonus(resultSet.getInt("bonus"));
+            list.add(emp);
+        }
+        return list;
+    }
+
+
+}

+ 48 - 0
JDBC/src/main/java/com/lc/jdbc2/Test01.java

@@ -0,0 +1,48 @@
+package com.lc.jdbc2;
+
+import com.alibaba.druid.pool.DruidDataSourceFactory;
+import org.junit.Test;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * ClassName: Test01
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 10:04
+ * @Version 1.0
+ */
+public class Test01 {
+
+    @Test
+    public void test01() throws Exception {
+        // 数据源信息
+        Map<String,String> dataSourse = new HashMap<>();
+
+        dataSourse.put("username","root");
+        dataSourse.put("password","123456");
+        dataSourse.put("url","jdbc:mysql://127.0.0.1:3306/db2?useSSL=false");
+
+        // 创建数据源
+        DataSource dataSource = DruidDataSourceFactory.createDataSource(dataSourse);
+
+        // 获取连接
+        Connection connection = dataSource.getConnection();
+
+        System.out.println(connection);
+    }
+
+
+    @Test
+    public void test02() throws Exception {
+        EmpDao empDao = new EmpDao();
+
+        List<Emp> all = empDao.getAll();
+        System.out.println(all);
+    }
+
+}

+ 23 - 0
JDBC/src/main/java/com/lc/jdbc3/Column.java

@@ -0,0 +1,23 @@
+package com.lc.jdbc3;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * ClassName: Column
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 11:27
+ * @Version 1.0
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface Column {
+
+    String property() default "";
+
+    String filed();
+
+}

+ 24 - 0
JDBC/src/main/java/com/lc/jdbc3/Table.java

@@ -0,0 +1,24 @@
+package com.lc.jdbc3;
+
+import org.junit.Test;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * ClassName: Table
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 11:23
+ * @Version 1.0
+ */
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface Table {
+
+    //抽象方法
+    String value() default "";
+}

+ 82 - 0
JDBC/src/main/java/com/lc/jdbc3/Test01.java

@@ -0,0 +1,82 @@
+package com.lc.jdbc3;
+
+import com.lc.utils.DButils;
+import org.junit.Test;
+
+import java.lang.reflect.Field;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * ClassName: Test01
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 11:31
+ * @Version 1.0
+ */
+public class Test01 {
+
+
+    @Test
+    public void test01() throws SQLException {
+        //class
+        Class<User> clazz = User.class;
+
+        String sql = " select ";
+
+        //判断是否有 Table
+        boolean annotationPresent = clazz.isAnnotationPresent(Table.class);
+        if (annotationPresent){
+
+            //获取字段
+            Field[] fields = clazz.getDeclaredFields();
+
+            for (Field field : fields) {
+
+                boolean anno = field.isAnnotationPresent(Column.class);
+
+                if (anno){
+                    //有注解
+                    Column annotation = field.getAnnotation(Column.class);
+                    String annoFiled = annotation.filed();
+
+                    sql+= annoFiled + " , ";
+                }else{
+                    //没有注解
+                    String filedName = field.getName();
+                    sql+= filedName + " , ";
+                }
+            }
+            sql+= " 1 ";
+
+            sql+= " from ";
+
+            //获取注解
+            Table annotation = clazz.getAnnotation(Table.class);
+            // 表名 value
+            String tUser = annotation.value();
+
+            sql += tUser + " ";
+        }
+
+        //执行 sql语句
+        System.out.println(sql);
+
+        //连接 DButils
+        Connection connection = DButils.getConnection();
+
+        PreparedStatement preparedStatement = connection.prepareStatement(sql);
+
+        ResultSet resultSet = preparedStatement.executeQuery();
+
+        while (resultSet.next()){
+            System.out.println(resultSet.getString("name"));
+        }
+
+        connection.close();
+
+    }
+
+}

+ 76 - 0
JDBC/src/main/java/com/lc/jdbc3/User.java

@@ -0,0 +1,76 @@
+package com.lc.jdbc3;
+
+/**
+ * ClassName: User
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 11:17
+ * @Version 1.0
+ */
+
+//@Table(value = "t_user")
+@Table("t_user")
+public class User {
+
+    private Integer id;
+    private String name;
+    private Integer age;
+    private String address;
+
+    @Column( property = "loginName", filed = "login_name")
+    private String loginName;
+
+    // 省略getter和setter方法
+
+
+    public String getLoginName() {
+        return loginName;
+    }
+
+    public void setLoginName(String loginName) {
+        this.loginName = loginName;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getAge() {
+        return age;
+    }
+
+    public void setAge(Integer age) {
+        this.age = age;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+
+    @Override
+    public String toString() {
+        return "User{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                ", age=" + age +
+                ", address='" + address + '\'' +
+                '}';
+    }
+}

+ 23 - 0
JDBC/src/main/java/com/lc/jdbc4/Column.java

@@ -0,0 +1,23 @@
+package com.lc.jdbc4;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * ClassName: Column
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 11:27
+ * @Version 1.0
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface Column {
+
+    String property() default "";
+
+    String filed();
+
+}

+ 85 - 0
JDBC/src/main/java/com/lc/jdbc4/Emp.java

@@ -0,0 +1,85 @@
+package com.lc.jdbc4;
+
+import java.util.Date;
+
+/**
+ * ClassName: Emp
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/25 15:50
+ * @Version 1.0
+ */
+@Table("emp")
+public class Emp {
+    private Integer id;
+    private String ename;
+    private Integer mgr;
+    private Date joindate;
+    private Double salary;
+    private Double bonus;
+
+
+    public Emp() {
+    }
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getEname() {
+        return ename;
+    }
+
+    public void setEname(String ename) {
+        this.ename = ename;
+    }
+
+    public Integer getMgr() {
+        return mgr;
+    }
+
+    public void setMgr(Integer mgr) {
+        this.mgr = mgr;
+    }
+
+    public Date getJoindate() {
+        return joindate;
+    }
+
+    public void setJoindate(Date joindate) {
+        this.joindate = joindate;
+    }
+
+    public Double getSalary() {
+        return salary;
+    }
+
+    public void setSalary(Double salary) {
+        this.salary = salary;
+    }
+
+    public Double getBonus() {
+        return bonus;
+    }
+
+    public void setBonus(Double bonus) {
+        this.bonus = bonus;
+    }
+
+    @Override
+    public String toString() {
+        return "Emp{" +
+                "id=" + id +
+                ", ename='" + ename + '\'' +
+                ", mgr='" + mgr + '\'' +
+                ", joindate=" + joindate +
+                ", salary=" + salary +
+                ", bonus=" + bonus +
+                '}';
+    }
+}

+ 13 - 0
JDBC/src/main/java/com/lc/jdbc4/EmpDao.java

@@ -0,0 +1,13 @@
+package com.lc.jdbc4;
+
+import com.lc.utils.BaseDAO;
+
+/**
+ * ClassName: EmpDao
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 15:07
+ * @Version 1.0
+ */
+public class EmpDao extends BaseDAO<Emp> {
+}

+ 22 - 0
JDBC/src/main/java/com/lc/jdbc4/Table.java

@@ -0,0 +1,22 @@
+package com.lc.jdbc4;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * ClassName: Table
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 11:23
+ * @Version 1.0
+ */
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface Table {
+
+    //抽象方法
+    String value() default "";
+}

+ 47 - 0
JDBC/src/main/java/com/lc/jdbc4/Test01.java

@@ -0,0 +1,47 @@
+package com.lc.jdbc4;
+
+import org.junit.Test;
+
+import java.sql.SQLException;
+import java.util.List;
+
+/**
+ * ClassName: Test01
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 14:36
+ * @Version 1.0
+ */
+public class Test01 {
+
+    @Test
+    public void test01()  {
+        UserDao userDao = new UserDao();
+        //id获取
+        List<User> all = userDao.getAll();
+
+        System.out.println(all);
+    }
+
+    @Test
+    public void test02()  {
+        EmpDao empDao = new EmpDao();
+        //id获取
+        List<Emp> all = empDao.getAll();
+
+        System.out.println(all);
+    }
+
+
+
+    @Test
+    public void test03() throws Exception {
+        UserDao userDao = new UserDao();
+        User user = new User();
+        user.setName("ls");
+        user.setAge(18);
+        user.setLoginName("ls");
+        userDao.insert(user);
+        System.out.println("插入成功");
+    }
+}

+ 77 - 0
JDBC/src/main/java/com/lc/jdbc4/User.java

@@ -0,0 +1,77 @@
+package com.lc.jdbc4;
+
+/**
+ * ClassName: User
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 11:17
+ * @Version 1.0
+ */
+
+//@Table(value = "t_user")
+@Table("t_user")
+public class User {
+
+    private Integer id;
+    private String name;
+    private Integer age;
+    private String address;
+
+    @Column( property = "loginName", filed = "login_name")
+    private String loginName;
+
+    // 省略getter和setter方法
+
+
+    public String getLoginName() {
+        return loginName;
+    }
+
+    public void setLoginName(String loginName) {
+        this.loginName = loginName;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getAge() {
+        return age;
+    }
+
+    public void setAge(Integer age) {
+        this.age = age;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+
+    @Override
+    public String toString() {
+        return "User{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                ", age=" + age +
+                ", address='" + address + '\'' +
+                ", loginName='" + loginName + '\'' +
+                '}';
+    }
+}

+ 14 - 0
JDBC/src/main/java/com/lc/jdbc4/UserDao.java

@@ -0,0 +1,14 @@
+package com.lc.jdbc4;
+
+import com.lc.utils.BaseDAO;
+
+/**
+ * ClassName: UserDao
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 14:35
+ * @Version 1.0
+ */
+public class UserDao extends BaseDAO<User> {
+
+}

+ 23 - 0
JDBC/src/main/java/com/lc/jdbc5/Column.java

@@ -0,0 +1,23 @@
+package com.lc.jdbc5;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * ClassName: Column
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 11:27
+ * @Version 1.0
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface Column {
+
+    String property() default "";
+
+    String filed();
+
+}

+ 14 - 0
JDBC/src/main/java/com/lc/jdbc5/EmpDao.java

@@ -0,0 +1,14 @@
+package com.lc.jdbc5;
+
+import com.lc.jdbc4.Emp;
+import com.lc.utils.BaseDAO;
+
+/**
+ * ClassName: EmpDao
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 15:07
+ * @Version 1.0
+ */
+public class EmpDao extends BaseDAO<Emp> {
+}

+ 39 - 0
JDBC/src/main/java/com/lc/jdbc5/Person.java

@@ -0,0 +1,39 @@
+package com.lc.jdbc5;
+
+
+/**
+ * ClassName: Person
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 16:06
+ * @Version 1.0
+ */
+@Table("t_person")
+public class Person {
+    private Integer id;
+    private String name;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String toString() {
+        return "Person{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                '}';
+    }
+}

+ 14 - 0
JDBC/src/main/java/com/lc/jdbc5/PersonDao.java

@@ -0,0 +1,14 @@
+package com.lc.jdbc5;
+
+import com.lc.utils.BaseDAO;
+
+/**
+ * ClassName: PersonDao
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 16:07
+ * @Version 1.0
+ */
+public class PersonDao extends BaseDAO<Person> {
+
+}

+ 21 - 0
JDBC/src/main/java/com/lc/jdbc5/Table.java

@@ -0,0 +1,21 @@
+package com.lc.jdbc5;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * ClassName: Table
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 11:23
+ * @Version 1.0
+ */
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface Table {
+    //抽象方法
+    String value() default "";
+}

+ 62 - 0
JDBC/src/main/java/com/lc/jdbc5/Test01.java

@@ -0,0 +1,62 @@
+package com.lc.jdbc5;
+
+import org.junit.Test;
+
+import java.util.List;
+
+/**
+ * ClassName: Test01
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 16:08
+ * @Version 1.0
+ */
+public class Test01 {
+    @Test
+    public void test01() throws Exception {
+        PersonDao personDao = new PersonDao();
+        Person person = new Person();
+        person.setId(2);
+        person.setName("ffff");
+
+        int insert = personDao.insert(person);
+
+    }
+
+    @Test
+    public void test02(){
+        PersonDao personDao = new PersonDao();
+
+        List<Person> all = personDao.getAll();
+
+        System.out.println(all);
+    }
+
+    @Test
+    public void test03() throws Exception {
+        PersonDao personDao = new PersonDao();
+
+        int del = personDao.del(1);
+
+    }
+
+    @Test
+    public void test04() throws Exception {
+        PersonDao personDao = new PersonDao();
+
+        Person id = personDao.getId(2);
+        System.out.println(id);
+    }
+
+    @Test
+    public void test05() throws Exception {
+        PersonDao personDao = new PersonDao();
+        Person person = new Person();
+        person.setId(2);
+        person.setName("aaa");
+        int update = personDao.update(person);
+        System.out.println(update);
+    }
+
+
+}

BIN
JDBC/src/main/java/com/lc/lc.zip


+ 224 - 0
JDBC/src/main/java/com/lc/utils/BaseDAO.java

@@ -0,0 +1,224 @@
+package com.lc.utils;
+
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.lc.jdbc5.*;
+
+
+/**
+ * ClassName: BaseDao
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 14:30
+ * @Version 1.0
+ */
+public class BaseDAO<T> {
+
+    static Connection connection = null;
+    //获取连接
+    static {
+        //获取连接
+        try {
+            connection  = DButils.getConnection();
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public int insert(T t) throws Exception {
+        Class<T> clazz = (Class<T>) t.getClass();
+
+        String sql = "insert into " + getTableName(clazz) + "( "+getFiledSql(clazz)+" ) values ( ";
+
+        Field[] declaredFields = clazz.getDeclaredFields();
+        int length = declaredFields.length;
+        for (int i = 0; i < length; i++) {
+            if (i== length - 1){
+                sql+= " ?  );";
+            }else{
+                sql+= " ?,";
+            }
+        }
+
+        PreparedStatement preparedStatement = connection.prepareStatement(sql);
+
+        for (int i = 1; i <= declaredFields.length; i++) {
+            declaredFields[i-1].setAccessible(true);
+
+            preparedStatement.setObject(i,declaredFields[i-1].get(t));
+        }
+
+        return preparedStatement.executeUpdate();
+    }
+
+    public int update(T t) throws Exception {
+        Class<T> clazz = (Class<T>) t.getClass();
+
+        String sql = " update " + getTableName(clazz) + " set ";
+
+        Field[] declaredFields = clazz.getDeclaredFields();
+
+        for (Field declaredField : declaredFields) {
+            String filedName = filedName(declaredField);
+            if (!declaredField.getName().equals("id")){
+                sql+= " " + filedName + " = ? , ";
+            }
+        }
+        sql = sql.substring(0, sql.length() - 2); // 去除最后一个逗号和空格
+
+        sql+= " where id = ?  ";
+        
+        PreparedStatement preparedStatement = connection.prepareStatement(sql);
+
+        int index = 0;
+        for (Field declaredField : declaredFields) {
+            if (!declaredField.getName().equals("id")){
+                declaredField.setAccessible(true);
+                preparedStatement.setObject(index,declaredField.get(t));
+            }
+            index++;
+        }
+        Field id = clazz.getDeclaredField("id");
+        id.setAccessible(true);
+        preparedStatement.setObject(index++,id.get(t));
+
+        return preparedStatement.executeUpdate();
+    }
+
+    public int del(int id) throws Exception {
+        Class<T> clazzClass = getClazzClass();
+        String sql = " delete from " + getTableName(clazzClass) + " where id = ? ";
+        PreparedStatement preparedStatement = connection.prepareStatement(sql);
+        preparedStatement.setObject(1,id);
+        return preparedStatement.executeUpdate();
+    }
+
+    public List<T> getAll()  {
+        //this 子类
+        try {
+            Class<T> clazz = getClazzClass();
+            //sql
+            String sql = "select " + getFiledSql(clazz) + " from " + getTableName(clazz);
+
+            //连接 DButils
+            Connection connection = DButils.getConnection();
+            PreparedStatement preparedStatement = connection.prepareStatement(sql);
+            //结果
+            ResultSet rs = preparedStatement.executeQuery();
+
+            List<T> list = new ArrayList<>();
+
+            while (rs.next()){
+                Constructor<T> constructor = clazz.getConstructor();
+                T t = constructor.newInstance();
+                //反射完成赋值
+                Field[] declaredFields = clazz.getDeclaredFields();
+                for (Field declaredField : declaredFields) {
+                    declaredField.setAccessible(true);
+                    declaredField.set(t,rs.getObject(filedName(declaredField)));
+                }
+                list.add(t);
+            }
+
+            return  list;
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public T getId(int id)  {
+        //this 子类
+        try {
+            Class<T> clazz = getClazzClass();
+
+            //sql
+            String sql = "select " + getFiledSql(clazz) + " from " + getTableName(clazz) + " where id = ? ";
+
+            //连接 DButils
+            Connection connection = DButils.getConnection();
+            PreparedStatement preparedStatement = connection.prepareStatement(sql);
+            //设置参数
+            preparedStatement.setInt(1,id);
+            //结果
+            ResultSet rs = preparedStatement.executeQuery();
+            //反射
+            return  getT(rs, clazz);
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+
+    public T getT(ResultSet rs , Class<T> clazz) throws Exception{
+
+        Constructor<T> constructor = clazz.getConstructor();
+        T t = constructor.newInstance();
+
+        while (rs.next()){
+            //反射完成赋值
+            Field[] declaredFields = clazz.getDeclaredFields();
+            for (Field declaredField : declaredFields) {
+                declaredField.setAccessible(true);
+                declaredField.setAccessible(true);
+                declaredField.set(t,rs.getObject(filedName(declaredField)));
+            }
+        }
+        return t;
+
+    }
+
+    private String getTableName(Class<T> clazz) {
+        //获取表名
+        if (clazz.isAnnotationPresent(Table.class)){
+            return clazz.getAnnotation(Table.class).value();
+        }else {
+            return clazz.getSimpleName();
+        }
+    }
+
+    private String getFiledSql(Class<T> clazz){
+        String filedSql = "";
+        //获取字段
+        Field[] fields = clazz.getDeclaredFields();
+        for (Field field : fields) {
+            //获取字段名
+            filedSql += filedName(field) + " , ";
+        }
+        filedSql = filedSql.substring(0,filedSql.lastIndexOf(","));
+
+        return filedSql;
+    }
+
+    public String filedName(Field field){
+        if (field.isAnnotationPresent(Column.class)){
+            //有注解
+            return field.getAnnotation(Column.class).filed();
+        }else{
+            //没有注解
+           return field.getName();
+        }
+    }
+
+    public Class<T> getClazzClass() throws ClassNotFoundException {
+        Class clazz = this.getClass();
+        //获取父类泛型类型
+        ParameterizedType genericSuperclass = (ParameterizedType) clazz.getGenericSuperclass();
+        //泛型
+        Type cla = genericSuperclass.getActualTypeArguments()[0];
+        //javabean的class
+        Class<T> typeClazz = (Class<T>) Class.forName(cla.getTypeName());
+        return typeClazz;
+    }
+}

+ 56 - 0
JDBC/src/main/java/com/lc/utils/DButils.java

@@ -0,0 +1,56 @@
+package com.lc.utils;
+
+import com.alibaba.druid.pool.DruidDataSourceFactory;
+
+import javax.sql.DataSource;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Properties;
+
+/**
+ * ClassName: DButils
+ *
+ * @Author 爱扣钉-陈晨
+ * @Create 2024/1/28 10:27
+ * @Version 1.0
+ */
+public class DButils {
+
+    private static DataSource dataSource= null;
+
+    //使用
+    static {
+        try {
+            //Properties
+            Properties properties = new Properties();
+            // 数据源信息
+            InputStream dataSourse = DButils.class.getClassLoader().getResourceAsStream("jdbc.properties");
+            //加载配置文件配置文件
+            properties.load(dataSourse);
+            // 创建数据源
+            dataSource = DruidDataSourceFactory.createDataSource(properties);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /*
+       获取连接
+     */
+    public static Connection getConnection() throws SQLException {
+
+        return dataSource.getConnection();
+    }
+
+    /*
+   获取连接
+ */
+    public static DataSource getDataSource() throws SQLException {
+        //单例
+        return dataSource;
+    }
+
+
+}

+ 10 - 0
JDBC/src/main/resources/jdbc.properties

@@ -0,0 +1,10 @@
+driverClassName=com.mysql.jdbc.Driver
+url=jdbc:mysql:///db2?useSSL=false&useServerPrepStmts=true
+username=root
+password=123456
+# ???????
+initialSize=5
+# ?????
+maxActive=10
+# ??????
+maxWait=3000

+ 16 - 0
JavaSE/.idea/compiler.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <annotationProcessing>
+      <profile name="Maven default annotation processors profile" enabled="true">
+        <sourceOutputDir name="target/generated-sources/annotations" />
+        <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
+        <outputRelativeToContentRoot value="true" />
+        <module name="dayapi" />
+        <module name="day06" />
+        <module name="day05" />
+        <module name="day04" />
+      </profile>
+    </annotationProcessing>
+  </component>
+</project>

+ 20 - 0
JavaSE/.idea/jarRepositories.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RemoteRepositoriesConfiguration">
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Central Repository" />
+      <option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Maven Central repository" />
+      <option name="url" value="https://repo1.maven.org/maven2" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="jboss.community" />
+      <option name="name" value="JBoss Community repository" />
+      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
+    </remote-repository>
+  </component>
+</project>

+ 16 - 0
JavaSE/day04/pom.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.sf</groupId>
+    <artifactId>day04</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+</project>

+ 55 - 0
JavaSE/day04/src/main/java/com/sf/Day04.java

@@ -0,0 +1,55 @@
+package com.sf;
+
+public class Day04 {
+    public static void main(String[] args) {
+        int a = 1;
+        a=2;
+        /**
+         * 定义数组
+         *  语法:数据类型[] 数组的变量名
+         *  定义了一个数据类型为int类型,变量名为arr的整形数组
+         */
+        int[] arr;
+
+        /**
+         * 定义数组的方式二
+         * 数据类型 变量名[];
+         * 定义了一个int类型的变量,变量名是arr数组
+         */
+        int arr2[];
+
+        double[] aa;
+        double bb[];
+        String[] cc;  //推荐
+        String dd[];
+
+/**
+ * 数组的静态初始化,
+ * 语法:数据类型[] 变量名 = new 数据类型[]{数据1,数据2,数据3,…};
+ */
+        int[]  ee = new int[]{1,2,3,4};
+
+
+        /**
+         * int[] arr;
+         * arr = new int[]{1,2,3,4,5};//正确
+         */
+        int[] abc;
+        abc = new int[]{5,6,7,8};
+
+
+        /**
+         * 简化格式:
+         * 数据类型[] 变量名 = {数据1,数据2,数据3,…};
+         */
+        int[] ff = {1,2,3};   //常用  推荐
+        String[] person = {"qq","ww","ee"};
+        String[] person1 = new String[]{"qq","ww","ee"};
+        int[] gg;
+        gg= new int[]{1, 2, 3};
+
+
+
+    }
+
+}

+ 12 - 0
JavaSE/day04/src/main/java/com/sf/Test1.java

@@ -0,0 +1,12 @@
+package com.sf;
+
+public class Test1 {
+    public static void main(String[] args) {
+        int[] arr = {1,2,3,4,5};
+        char[] word = {'h','e','l','l','o'};
+        String[] heros = {"袁隆平","邓稼先","钱学森"};
+        System.out.println(arr);
+        System.out.println(word);
+        System.out.println(heros);
+    }
+}

+ 41 - 0
JavaSE/day04/src/main/java/com/sf/Test2.java

@@ -0,0 +1,41 @@
+package com.sf;
+
+public class Test2 {
+    public static void main(String[] args) {
+
+
+        String[] str = {"电视剧1", "电视剧2", "电视剧3", "电视剧4", "电视剧5", "电视剧6"};
+
+        String[] subject = {"学科1", "学科2", "学科3", "学科4", "学科5", "学科6"};
+
+        int[] score = {99, 98, 97, 96, 95};
+        int length = score.length;
+//        System.out.println("数组的长度"+length);
+
+        /**
+         * 数组名[索引/下标]
+         */
+        String[] person = {"张三","李四","王五","赵六","孙七","李八","王九"};
+        System.out.println("当前数组的长度"+person.length);
+        String zs = person[0]; //张三
+        System.out.println(zs);
+        String ls = person[1]; //李四
+        System.out.println(ls);
+        String ww = person[2]; //王五
+        System.out.println(ww);
+//        System.out.println(person[3]);
+
+//        //张三和王五换个位置
+//        person[0]="王五";
+//        person[2]="张三";
+//        System.out.println("更改后的"+person[2]);
+//
+        System.out.println(person.length);
+        for (int i = 0 ;i< person.length;i++){
+            String person1 = person[i];
+            System.out.println(person1);
+        }
+
+
+    }
+}

+ 26 - 0
JavaSE/day04/src/main/java/com/sf/Test3.java

@@ -0,0 +1,26 @@
+package com.sf;
+
+public class Test3 {
+    /**
+     * 求和   求平均值
+     * @param args
+     */
+    public static void main(String[] args) {
+        int[] arr = {4,5,6,1,9};
+        int sum = 0;
+        for (int i=0 ; i< arr.length;i++){
+            sum += arr[i];
+        }
+        System.out.println("当前总和==="+sum);
+        //平均值  sum/arr.length
+        if(arr.length > 0){
+            int avg = sum/arr.length ;
+            System.out.println("当前数组的平均值==>"+avg);
+        }else {
+            System.out.println("当前数组为空");
+        }
+
+
+
+    }
+}

+ 21 - 0
JavaSE/day04/src/main/java/com/sf/Test4.java

@@ -0,0 +1,21 @@
+package com.sf;
+
+public class Test4 {
+    public static void main(String[] args) {
+        int[] scores = {5,4,6,8,9,0,1,2,7,3};
+        int max = scores[0];
+        int min = scores[0];
+        int sum = 0;
+        for(int i = 0;i < scores.length;i++){
+            if(max < scores[i]){
+                max = scores[i];
+            }
+            if(min > scores[i]){
+                min = scores[i];
+            }
+            sum += scores[i];
+        }
+        double avg = (double)(sum - max - min) / (scores.length - 2);
+        System.out.println("选手去掉最高分和最低分之后的平均分为:" + avg);
+    }
+}

+ 41 - 0
JavaSE/day04/src/main/java/com/sf/Test5.java

@@ -0,0 +1,41 @@
+package com.sf;
+
+public class Test5 {
+    public static void main(String[] args) {
+        /**   动态初始化
+         * 数组存储的元素的数据类型[] 数组名字 = new 数组存储的元素的数据类型[长度];
+         * 或
+         * 数组存储的数据类型[] 数组名字;
+         * 数组名字 = new 数组存储的数据类型[长度];
+         */
+        int[] aa = new int[3];
+        int[] bb;
+        bb = new int[4];
+//        for (int i =0;i<aa.length;i++ ){
+//            aa[i]=1;
+//        }
+            aa[0]=1;
+            aa[1]=2;
+            aa[2]=3;
+        for (int i =0;i<aa.length;i++ ){
+            System.out.println(aa[i]);
+        }
+
+        /*
+        基本数据类型
+         */
+        int[] vv = new int[5];
+        for (int i =0;i<vv.length;i++){
+            System.out.println(vv[i]);
+        }
+
+
+        /**
+         * 包装类
+         */
+        Integer[] mm = new Integer[5];
+        for (int i =0;i<mm.length;i++){
+            System.out.println(mm[i]);
+        }
+    }
+}

+ 21 - 0
JavaSE/day04/src/main/java/com/sf/Test6.java

@@ -0,0 +1,21 @@
+package com.sf;
+
+public class Test6 {
+    public static void main(String[] args) {
+        int[][] aa={{12,14,24},{23,18,35},{33,48,25},{27,28,35}};
+
+        int sum = 0;
+        int time  = 0;
+        for (int i =0;i<aa.length;i++){
+            for (int j = 0; j<aa[i].length;j++){
+               int bb = aa[i][j];
+               sum += bb;
+               time++;
+            }
+        }
+        System.out.println("sum==="+sum);
+        System.out.println("time==="+time);
+        System.out.println("平均值==="+sum/time);
+    }
+
+}

+ 16 - 0
JavaSE/day05/pom.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.sf</groupId>
+    <artifactId>day05</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+</project>

+ 33 - 0
JavaSE/day05/src/main/java/com/sf/BinFind.java

@@ -0,0 +1,33 @@
+package com.sf;
+
+/**
+ * 二分查找
+ */
+public class BinFind {
+    public static void main(String[] args) {
+        //二分法查找:要求此数组必须是有序的。
+        int[] arr3 = new int[]{-99,-54,-2,0,2,33,43,256,999};
+        boolean isFlag = true;
+        int value = 256;
+//int value = 25;
+        int head = 0;//首索引位置
+        int end = arr3.length - 1;//尾索引位置
+        while(head <= end){
+            int middle = (head + end) / 2;
+            if(arr3[middle] == value){
+                System.out.println("找到指定的元素,索引为:" + middle);
+                isFlag = false;
+                break;
+            }else if(arr3[middle] > value){
+                end = middle - 1;
+            }else{//arr3[middle] < value
+                head = middle + 1;
+            }
+        }
+
+        if(isFlag){
+            System.out.println("未找打指定的元素");
+        }
+
+    }
+}

+ 100 - 0
JavaSE/day05/src/main/java/com/sf/Test1.java

@@ -0,0 +1,100 @@
+package com.sf;
+
+
+import javax.xml.transform.Source;
+import java.util.Arrays;
+
+public class Test1 {
+    public static void main(String[] args) {
+//        int[] aa = new int[5];
+//        for (int i= 0 ;i <aa.length;i++){
+//            aa[i] = i+1;
+//            System.out.println("数组元素"+aa[i]);
+//        }
+//        System.out.println("========================================");
+//        aa = null;
+//        System.out.println(aa[2]);
+/**
+ * 数组排序
+ */
+        int[] aa = {1,9,3,5,2,4,7,8};
+        Arrays.sort(aa,1,6);
+        System.out.println(Arrays.toString(aa));
+        /**
+         * 字符串排序
+         */
+        String[] str = {"zhangsan","lisi","gu"};
+        Arrays.sort(str);
+        System.out.println(Arrays.toString(str));
+
+        /**
+         * 二分查找
+         */
+        int[] bin = {1,2,3,4,5,6,7,8,9};
+        int i = Arrays.binarySearch(bin, 7);
+        System.out.println(i);
+
+        /**
+         * 数组的复制
+         */
+        int[] bin2 = {1,2,3,4,5,6,7,8,9};
+        int[] newBin2 = Arrays.copyOf(bin2, bin2.length);
+        System.out.println(Arrays.toString(newBin2));
+
+        int[] newBin3 = Arrays.copyOfRange(bin2, 0, 3);    //包左不包右
+        System.out.println(Arrays.toString(newBin3));
+
+        String[] str2 = {"zhangsan","lisi","gu"};
+        String[] newStr2 = Arrays.copyOf(str2, str2.length);
+        System.out.println(Arrays.toString(newStr2));
+
+        String[] newStr3 = Arrays.copyOfRange(str2, 0, 2);
+        System.out.println(Arrays.toString(newStr3));  //包左不包右
+
+        /**
+         *比较两个数组是否相等
+         */
+        int[] bin3 = {1,2,3,4,5,6,7,8,9};
+        int[] bin4 = {1,2,3,4,5,6,7,8,9};
+        int[] bin5 = {1,2,3,4,5};
+
+        boolean equals = Arrays.equals(bin3, bin4);
+        System.out.println("bin3==bin4======>"+equals);
+
+        boolean equals2 = Arrays.equals(bin3, bin5);
+        System.out.println("bin3==bin5=========>"+equals2);
+
+        /**
+         * 数组的填充
+         */
+        int[] cc = new int[5];
+        System.out.println(Arrays.toString(cc));
+
+        Arrays.fill(cc,5);
+        System.out.println(Arrays.toString(cc));
+        /**
+         * 用对象进行填充数组
+         */
+        String[] dd = new String[5];
+        System.out.println(Arrays.toString(dd));
+
+        Arrays.fill(dd,"这回不是null");
+        System.out.println(Arrays.toString(dd));
+
+
+        /**
+         * 将a数组[fromIndex,toIndex)部分填充为val值
+         */
+        int[] ff = new int[5];
+        System.out.println(Arrays.toString(ff));
+
+        Arrays.fill(ff,0,4,99); //包左不包右
+        System.out.println(Arrays.toString(ff));
+
+        String[] ee = new String[9];
+        System.out.println(Arrays.toString(ee));
+
+        Arrays.fill(ee,0,4,"非空啦");//包左不包右
+        System.out.println(Arrays.toString(ee));
+    }
+}

+ 89 - 0
JavaSE/day05/src/main/java/com/sf/Test19BubbleSort.java

@@ -0,0 +1,89 @@
+package com.sf;
+
+/*
+ 1、冒泡排序(最经典)
+思想:每一次比较“相邻(位置相邻)”元素,如果它们不符合目标顺序(例如:从小到大),
+     就交换它们,经过多轮比较,最终实现排序。
+	 (例如:从小到大)	 每一轮可以把最大的沉底,或最小的冒顶。
+
+过程:arr{6,9,2,9,1}  目标:从小到大
+
+第一轮:
+	第1次,arr[0]与arr[1],6>9不成立,满足目标要求,不交换
+	第2次,arr[1]与arr[2],9>2成立,不满足目标要求,交换arr[1]与arr[2] {6,2,9,9,1}
+	第3次,arr[2]与arr[3],9>9不成立,满足目标要求,不交换
+	第4次,arr[3]与arr[4],9>1成立,不满足目标要求,交换arr[3]与arr[4] {6,2,9,1,9}
+	第一轮所有元素{6,9,2,9,1}已经都参与了比较,结束。
+	第一轮的结果:第“一”最大值9沉底(本次是后面的9沉底),即到{6,2,9,1,9}元素的最右边
+
+第二轮:
+	第1次,arr[0]与arr[1],6>2成立,不满足目标要求,交换arr[0]与arr[1] {2,6,9,1,9}
+	第2次,arr[1]与arr[2],6>9不成立,满足目标要求,不交换
+	第3次:arr[2]与arr[3],9>1成立,不满足目标要求,交换arr[2]与arr[3] {2,6,1,9,9}
+	第二轮未排序的所有元素 {6,2,9,1}已经都参与了比较,结束。
+	第二轮的结果:第“二”最大值9沉底(本次是前面的9沉底),即到{2,6,1,9}元素的最右边
+第三轮:
+	第1次,arr[0]与arr[1],2>6不成立,满足目标要求,不交换
+	第2次,arr[1]与arr[2],6>1成立,不满足目标要求,交换arr[1]与arr[2] {2,1,6,9,9}
+	第三轮未排序的所有元素{2,6,1}已经都参与了比较,结束。
+	第三轮的结果:第三最大值6沉底,即到 {2,1,6}元素的最右边
+第四轮:
+	第1次,arr[0]与arr[1],2>1成立,不满足目标要求,交换arr[0]与arr[1] {1,2,6,9,9}
+	第四轮未排序的所有元素{2,1}已经都参与了比较,结束。
+	第四轮的结果:第四最大值2沉底,即到{1,2}元素的最右边
+*/
+public class Test19BubbleSort{
+    public static void main(String[] args){
+        int[] arr = {6,9,2,9,1};
+
+        //目标:从小到大
+        //冒泡排序的轮数 = 元素的总个数 - 1
+        //轮数是多轮,每一轮比较的次数是多次,需要用到双重循环,即循环嵌套
+        //外循环控制 轮数,内循环控制每一轮的比较次数和过程
+        for(int i=1; i<arr.length; i++){ //循环次数是arr.length-1次/轮
+			/*
+			假设arr.length=5
+			i=1,第1轮,比较4次
+				arr[0]与arr[1]
+				arr[1]与arr[2]
+				arr[2]与arr[3]
+				arr[3]与arr[4]
+
+				arr[j]与arr[j+1],int j=0;j<4; j++
+
+			i=2,第2轮,比较3次
+				arr[0]与arr[1]
+				arr[1]与arr[2]
+				arr[2]与arr[3]
+
+				arr[j]与arr[j+1],int j=0;j<3; j++
+
+			i=3,第3轮,比较2次
+				arr[0]与arr[1]
+				arr[1]与arr[2]
+
+				arr[j]与arr[j+1],int j=0;j<2; j++
+			i=4,第4轮,比较1次
+				arr[0]与arr[1]
+
+				arr[j]与arr[j+1],int j=0;j<1; j++
+
+				int j=0; j<arr.length-i; j++
+			*/
+            for(int j=0; j<arr.length-i; j++){
+                //希望的是arr[j] < arr[j+1]
+                if(arr[j] > arr[j+1]){
+                    //交换arr[j]与arr[j+1]
+                    int temp = arr[j];
+                    arr[j] = arr[j+1];
+                    arr[j+1] = temp;
+                }
+            }
+        }
+
+        //完成排序,遍历结果
+        for(int i=0; i<arr.length; i++){
+            System.out.print(arr[i]+"  ");
+        }
+    }
+}

+ 34 - 0
JavaSE/day05/src/main/java/com/sf/Test19BubbleSort2.java

@@ -0,0 +1,34 @@
+package com.sf;
+
+/*
+思考:冒泡排序是否可以优化
+*/
+class Test19BubbleSort2{
+    public static void main(String[] args) {
+        int[] arr = {1, 3, 5, 7, 9};
+
+        //从小到大排序
+        for (int i = 0; i < arr.length - 1; i++) {
+            boolean flag = true;//假设数组已经是有序的
+            for (int j = 0; j < arr.length - 1 - i; j++) {
+                //希望的是arr[j] < arr[j+1]
+                if (arr[j] > arr[j + 1]) {
+                    //交换arr[j]与arr[j+1]
+                    int temp = arr[j];
+                    arr[j] = arr[j + 1];
+                    arr[j + 1] = temp;
+
+                    flag = false;//如果元素发生了交换,那么说明数组还没有排好序
+                }
+            }
+            if (flag) {
+                break;
+            }
+        }
+
+        //完成排序,遍历结果
+        for (int i = 0; i < arr.length; i++) {
+            System.out.print(arr[i] + "  ");
+        }
+    }
+}

+ 88 - 0
JavaSE/day05/src/main/java/com/sf/Test2.java

@@ -0,0 +1,88 @@
+package com.sf;
+
+import javax.naming.InsufficientResourcesException;
+public class Test2 {
+    public static void main(String[] args) {
+        String[] class1 = {"qq","ww","ee"};
+        String[] class2 = {"rr","tt","yy"};
+        String[] class3 = {"uu","ii","oo"};
+
+        /**
+         * 声明二维数组
+         * 1、元素的数据类型[][] 二维数组的名称;
+         * 2、元素的数据类型  二维数组名[][];
+         * 3、元素的数据类型[]  二维数组名[];
+         */
+        String[][] classTwo;   //推荐
+        String classTwo2[][];
+        String[] classTwo3[];
+
+        /**
+         * 将三个班级,每个班级中的三个同学  都放在一个二维数组里
+         * [][]
+         *      第一个中括号代表的是 二维数组中的第一个元素
+         *      第二个中括号代表的是  二维数组中的第一个元素(一维数组)中的每一个元素
+         */
+        String[][] className = {{"qq","ww","ee"},{"rr","tt","yy"},{"uu","ii","oo"}};
+        for (int k = 0; k<className.length;k++){
+            System.out.println("循环次数"+k);
+            for (int z = 0;z < className[k].length;z++){
+                String s = className[k][z];
+                System.out.println(s);
+                System.out.println("第一个元素的长度"+ className[k].length);
+
+            }
+        }
+
+        String name = className[0][0];
+//        System.out.println("qq"+name);
+//        System.out.println("yy===>"+className[1][2]);
+
+        String[][] className2 = new String[][]{{"qq","ww","ee"},{"rr","tt","yy"},{"uu","ii","oo"}};
+        String[][] className3;
+        className3 =  new String[][]{{"qq","ww","ee"},{"rr","tt","yy"},{"uu","ii","oo"}};
+
+        /**
+         * [1]  : 二维数组中 包含2个一维数组    行
+         * [2]  : 每个一维数组中的元素个数为3个  列
+         */
+        String[][]  arr = new String[2][3];
+        arr[0][0] = "张三0";
+        arr[0][1] = "张三1";
+        arr[0][2] = "张三2";
+//        第二个一维数组赋值
+        arr[1][0] = "张四0";
+        arr[1][1] = "张四1";
+        arr[1][2] = "张四2";
+
+        System.out.println(arr[1][1]);
+        /**
+         * 获取二维数组的长度    获取二维数组中一维数组(第一个元素)的的长度
+         */
+        int length = arr.length;
+        int length1 = arr[0].length;
+
+        System.out.println(length);
+        System.out.println("================="+length1);
+
+
+        /**
+         * 二维数组的遍历
+         */
+        String[][] name1 = new String[][]{{"qq","ww","ee"},{"rr","tt","yy"},{"uu","ii","oo"}};
+
+
+
+        int[][] xs = {{12,14,24},{23,18,35},{33,48,25},{27,28,35}};
+        int sum = 0;
+        int count = 0; //数组长度
+        for (int q = 0 ;q<xs.length;q++){
+            for (int e = 0 ;e <xs[q].length;e++){
+                sum+=xs[q][e];
+                count++;
+            }
+        }
+        System.out.println("总和为"+sum);
+        System.out.println("平均值"+sum/count);
+    }
+}

+ 46 - 0
JavaSE/day05/src/main/java/com/sf/Test3.java

@@ -0,0 +1,46 @@
+package com.sf;
+
+/**
+ * 杨辉三角
+ */
+public class Test3 {
+    /**
+     * @author 爱扣钉-陈晨
+     * @create 10:11
+     */
+        public static void main(String[] args) {
+
+            //1. 动态初始化的方式创建二维数组
+            int[][] yangHui = new int[10][];
+
+            for (int i = 0; i < yangHui.length; i++) {
+                yangHui[i] = new int[i + 1];
+
+                //2. 给数组元素赋值
+                // 2.1 给外层数组元素中的首元素和末元素赋值
+                yangHui[i][0] = yangHui[i][i] = 1;
+
+                //2.2 给外层数组元素中的非首元素和非末元素赋值(难)
+                //if(i > 1){ //从 i == 2 开始执行
+                for(int j = 1;j < yangHui[i].length - 1;j++){
+                    //非首元素和非末元素的角标范围
+                    yangHui[i][j] = yangHui[i-1][j-1] + yangHui[i-1][j];
+
+                }
+                //}
+            }
+
+
+            //3. 遍历二维数组
+            for (int i = 0; i < yangHui.length; i++) {
+                for (int j = 0; j < yangHui[i].length; j++) {
+                    System.out.print(yangHui[i][j] + "\t");
+                }
+
+                System.out.println();
+            }
+
+        }
+}
+
+

+ 26 - 0
JavaSE/day05/src/main/java/com/sf/TestArrayOrderSearch.java

@@ -0,0 +1,26 @@
+package com.sf;
+
+/**
+ * 顺序查找
+ */
+public class TestArrayOrderSearch {
+    //查找value第一次在数组中出现的index
+    public static void main(String[] args){
+        int[] arr = {4,5,6,1,9};
+        int value = 1;
+        int index = -1;
+
+        for(int i=0; i<arr.length; i++){
+            if(arr[i] == value){
+                index = i;
+                break;
+            }
+        }
+
+        if(index==-1){
+            System.out.println(value + "不存在");
+        }else{
+            System.out.println(value + "的下标是" + index);
+        }
+    }
+}

+ 38 - 0
JavaSE/day05/src/main/java/com/sf/TestArrayReverse1.java

@@ -0,0 +1,38 @@
+package com.sf;
+
+/**
+ * 数组的反转
+ */
+public class TestArrayReverse1 {
+    public static void main(String[] args) {
+        int[] arr = {1,2,3,4,5};
+        System.out.println("反转之前:");
+        for (int i = 0; i < arr.length; i++) {
+            System.out.println(arr[i]);
+        }
+
+        //反转
+         /*
+        思路:首尾对应位置的元素交换
+        (1)确定交换几次
+           次数 = 数组.length / 2
+        (2)谁和谁交换
+        for(int i=0; i<次数; i++){
+             int temp = arr[i];
+             arr[i] = arr[arr.length-1-i];
+             arr[arr.length-1-i] = temp;
+        }
+         */
+        for(int i=0; i<arr.length/2; i++){
+            int temp = arr[i];
+            arr[i] = arr[arr.length-1-i];
+            arr[arr.length-1-i] = temp;
+        }
+
+        System.out.println("反转之后:");
+        for (int i = 0; i < arr.length; i++) {
+            System.out.println(arr[i]);
+        }
+    }
+
+}

+ 25 - 0
JavaSE/day05/src/main/java/com/sf/TestArrayReverse2.java

@@ -0,0 +1,25 @@
+package com.sf;
+
+public class TestArrayReverse2 {
+    public static void main(String[] args) {
+        int[] arr = {1,2,3,4,5};
+        System.out.println("反转之前:");
+        for (int i = 0; i < arr.length; i++) {
+            System.out.println(arr[i]);
+        }
+
+        //反转
+        //左右对称位置交换
+        for(int left=0,right=arr.length-1; left<right; left++,right--){
+            //首  与  尾交换
+            int temp = arr[left];
+            arr[left] = arr[right];
+            arr[right] = temp;
+        }
+
+        System.out.println("反转之后:");
+        for (int i = 0; i < arr.length; i++) {
+            System.out.println(arr[i]);
+        }
+    }
+}

BIN
JavaSE/day05/target/classes/com/sf/BinFind.class


BIN
JavaSE/day05/target/classes/com/sf/Test1.class


BIN
JavaSE/day05/target/classes/com/sf/Test19BubbleSort.class


BIN
JavaSE/day05/target/classes/com/sf/Test19BubbleSort2.class


BIN
JavaSE/day05/target/classes/com/sf/Test2.class


BIN
JavaSE/day05/target/classes/com/sf/Test3.class


BIN
JavaSE/day05/target/classes/com/sf/TestArrayOrderSearch.class


BIN
JavaSE/day05/target/classes/com/sf/TestArrayReverse1.class


BIN
JavaSE/day05/target/classes/com/sf/TestArrayReverse2.class


BIN
JavaSE/day05/target/classes/com/sf/TestYear.class


BIN
JavaSE/day05/target/classes/com/sf/YEARTest.class


+ 16 - 0
JavaSE/day06/pom.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.sf</groupId>
+    <artifactId>day06</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+</project>

+ 18 - 0
JavaSE/day06/src/main/java/com/sf/City.java

@@ -0,0 +1,18 @@
+package com.sf;
+
+public class City extends Country{
+    String name;
+
+    public void print() {
+        name = "Shanghai";
+        super.print();      //调用父类的方法
+        System.out.println(this.name);  //上海
+        System.out.println(super.name);    //China方法
+        System.out.println(name);
+    }
+
+    public static void main(String[] args) {
+        City city = new City();
+        city.print();
+    }
+}

+ 13 - 0
JavaSE/day06/src/main/java/com/sf/Country.java

@@ -0,0 +1,13 @@
+package com.sf;
+
+/**
+ * 国家类
+ */
+public class Country{
+    String name;
+    public void  print(){
+        System.out.println("这是super的方法");
+        name = "China方法";
+    }
+
+}

+ 17 - 0
JavaSE/day06/src/main/java/com/sf/Huashan.java

@@ -0,0 +1,17 @@
+package com.sf;
+
+/**
+ * 华山类
+ */
+public class Huashan {
+//    掌门
+    private String zhangmen;
+
+    public void liangong(){
+        System.out.println("这是练功行为");
+    }
+
+    public void jingong(){
+        System.out.println("出剑");
+    }
+}

+ 12 - 0
JavaSE/day06/src/main/java/com/sf/Jianzong.java

@@ -0,0 +1,12 @@
+package com.sf;
+
+/**
+ * 剑宗类
+ */
+public class Jianzong extends Huashan{
+
+    public void liangong(){
+        System.out.println("练剑为主,练气为辅");
+    }
+
+}

+ 31 - 0
JavaSE/day06/src/main/java/com/sf/Person.java

@@ -0,0 +1,31 @@
+package com.sf;
+
+public class Person {
+    private String name ="凤姐";
+    private int age = 20;
+
+    public Person() {
+        System.out.println("父类无参");
+    }
+
+    public Person(String name , int age){
+        this.name = name ;
+        this.age = age ;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+}

+ 11 - 0
JavaSE/day06/src/main/java/com/sf/Qizong.java

@@ -0,0 +1,11 @@
+package com.sf;
+
+/**
+ * 气宗类
+ */
+public class Qizong extends Huashan{
+
+    public void liangong(){
+        System.out.println("练气为主 , 练剑为辅");
+    }
+}

+ 35 - 0
JavaSE/day06/src/main/java/com/sf/Student.java

@@ -0,0 +1,35 @@
+package com.sf;
+
+public class Student extends Person{
+    private double score = 100;
+    public Student() {
+        //super(); // 调用父类无参构造方法,默认就存在,可以不写,必须再第一行
+        System.out.println("子类无参");
+    }
+
+    public Student(String name , int age,double score) {
+        super(name ,age);// 调用父类有参构造方法,初始化name和age
+        this.score = score;
+        System.out.println("子类有参");
+    }
+
+    public double getScore() {
+        return score;
+    }
+
+    public void setScore(double score) {
+
+        this.score = score;
+    }
+
+
+    public static void main(String[] args) {
+//        Student student = new Student();  //对象的创建
+        // 调用子类有参数构造方法
+        Student s2 = new Student("张三",20,99);   //属性的赋值
+        System.out.println(s2.getScore()); // 99
+        System.out.println(s2.getName()); // 输出 张三
+        System.out.println(s2.getAge()); // 输出 20
+    }
+}
+

+ 12 - 0
JavaSE/day06/src/main/java/com/sf/Test.java

@@ -0,0 +1,12 @@
+package com.sf;
+
+public class Test {
+    public static void main(String[] args) {
+        Jianzong jianzong = new Jianzong();
+        Qizong qizong = new Qizong();
+        jianzong.liangong();
+        qizong.liangong();
+        jianzong.jingong();
+        qizong.jingong();
+    }
+}

+ 16 - 0
JavaSE/day06/src/main/java/com/sf/codeBlock/Father.java

@@ -0,0 +1,16 @@
+package com.sf.codeBlock;
+
+public class Father {
+    {
+        System.out.println("(2)父类的非静态代码块");
+    }
+
+    static{
+        System.out.println("(1)父类的静态代码块");
+    }
+
+    Father(){
+        System.out.println("(3)父类的无参构造");
+    }
+
+}

+ 16 - 0
JavaSE/day06/src/main/java/com/sf/codeBlock/Son.java

@@ -0,0 +1,16 @@
+package com.sf.codeBlock;
+
+public class Son extends Father{
+    {
+        System.out.println("(5)子类的非静态代码块");
+    }
+
+    static{
+        System.out.println("(4)子类的静态代码块");
+    }
+
+
+    Son(){
+        System.out.println("(6)子类的无参构造");
+    }
+}

+ 20 - 0
JavaSE/day06/src/main/java/com/sf/codeBlock/Test1.java

@@ -0,0 +1,20 @@
+package com.sf.codeBlock;
+
+import com.sf.static2.Student2;
+
+/**
+ * 局部代码块
+ * 必须写在方法里  {   代码体   }
+ * 局部代码块  声明的变量只能在代码块的内部进行使用
+ */
+public class Test1 {
+
+    public static void main(String[] args) {
+//        代码块
+        {
+            int a  =1;
+            System.out.println(a);
+        }
+        System.out.println();
+    }
+}

+ 18 - 0
JavaSE/day06/src/main/java/com/sf/codeBlock/Test2.java

@@ -0,0 +1,18 @@
+package com.sf.codeBlock;
+
+/**
+ * 静态代码块
+ * static{  代码体 }
+ * 静态代码块必须放在类下
+ */
+public class Test2 {
+   private static int a;
+    static {
+         a =1;
+        System.out.println(a);
+    }
+
+    public static void main(String[] args) {
+        System.out.println(a);
+    }
+}

+ 29 - 0
JavaSE/day06/src/main/java/com/sf/codeBlock/Test3.java

@@ -0,0 +1,29 @@
+package com.sf.codeBlock;
+
+/**
+ * 实例(构造)代码块
+ */
+public class Test3 {
+    private String name;
+    {
+        System.out.println("实例代码块执行...");
+        name = "张三";
+    }
+
+    // 构造器
+    public Test3(){
+        System.out.println("无参构造方法执行...");
+    }
+
+    // 有参数构造器
+    public Test3(String name){
+        System.out.println("有参构造方法执行...");
+        this.name = name;
+    }
+
+    public static void main(String[] args) {
+        Test3 t1 = new Test3();
+        Test3 t2 = new Test3("李四");
+        System.out.println(t1.name + t2.name);
+    }
+}

+ 7 - 0
JavaSE/day06/src/main/java/com/sf/codeBlock/TestSonCode.java

@@ -0,0 +1,7 @@
+package com.sf.codeBlock;
+
+public class TestSonCode {
+    public static void main(String[] args) {
+        Son son = new Son();
+    }
+}

+ 20 - 0
JavaSE/day06/src/main/java/com/sf/final1/A.java

@@ -0,0 +1,20 @@
+package com.sf.final1;
+
+import javax.print.attribute.standard.PrinterURI;
+import java.sql.SQLOutput;
+
+public  class A {
+
+     String bb;
+
+    public A() {
+    }
+
+    public A(String bb) {
+        this.bb = bb;
+    }
+
+    public final   void method1(){
+        System.out.println("aaa == final");
+    }
+}

+ 12 - 0
JavaSE/day06/src/main/java/com/sf/final1/B.java

@@ -0,0 +1,12 @@
+package com.sf.final1;
+
+
+
+public class B extends A{
+    private static  final int AAAAAAAA= 1;  //常量  显示赋值   常量的变量名都是大写   多个单词组合的情况下 _ 例如  MAX_COUNT
+    public static void main(String[] args) {
+         final   String a;
+         a = "aa";
+    }
+
+}

+ 21 - 0
JavaSE/day06/src/main/java/com/sf/static2/Person.java

@@ -0,0 +1,21 @@
+package com.sf.static2;
+
+public class Person {
+    public static void method1(){
+        System.out.println("person ==>这是方法1");
+    }
+
+    public static void method2(){
+        System.out.println("person ==>这是方法2");
+    }
+
+    public void method3(){
+        System.out.println("person ==>这是方法3(非静态的)");
+    }
+
+
+    public static void main(String[] args) {
+        Person person = new Person();
+         person.method3();
+    }
+}

+ 39 - 0
JavaSE/day06/src/main/java/com/sf/static2/Student.java

@@ -0,0 +1,39 @@
+package com.sf.static2;
+
+public class Student {
+    //实例变量
+    String name;    //公开是
+    int age;
+    //类变量
+    static String major;//专业    静态的
+
+    public Student() {
+    }
+
+    public Student(String name, int age) {
+        this.name = name;
+        this.age = age;
+    }
+
+    @Override
+    public String toString() {
+        return "Student{" +
+                "name='" + name + '\'' +
+                ", age=" + age +
+                ", major='" + major + '\'' +
+                '}';
+    }
+
+    public static void main(String[] args) {
+        Student c1 = new Student("小小",36);
+        c1.major = "计算机科学与技术";
+
+        Student c2 = new Student("大大",66);
+
+        System.out.println(c1);  //Student{name='小小', age=36, major='计算机科学与技术'}
+        System.out.println(c2);   //Student{name='大大', age=66, major='计算机科学与技术'}
+
+        System.out.println(major);   //计算机科学与技术
+    }
+
+}

+ 8 - 0
JavaSE/day06/src/main/java/com/sf/static2/Student2.java

@@ -0,0 +1,8 @@
+package com.sf.static2;
+
+public class Student2 extends Person{
+
+    public static void method2(){
+        System.out.println("Son.m2");
+    }
+}

+ 9 - 0
JavaSE/day06/src/main/java/com/sf/static2/TestStatic.java

@@ -0,0 +1,9 @@
+package com.sf.static2;
+
+public class TestStatic {
+    public static void main(String[] args) {
+//        类名.方法名
+        Person.method1();
+        Person.method2();
+    }
+}

+ 15 - 0
JavaSE/day06/src/main/java/com/sf/static2/TestStaticMethod.java

@@ -0,0 +1,15 @@
+package com.sf.static2;
+
+public class TestStaticMethod {
+    public static void main(String[] args) {
+        Person.method1();
+        Student2.method2();//继承静态方法
+        Student2.method2();//执行Father类中的m1
+
+        Person person = new Student2();
+        person.method3();
+
+        Person.method2();
+        Student2.method2();
+    }
+}

BIN
JavaSE/day06/target/classes/com/sf/City.class


BIN
JavaSE/day06/target/classes/com/sf/Country.class


BIN
JavaSE/day06/target/classes/com/sf/Huashan.class


BIN
JavaSE/day06/target/classes/com/sf/Jianzong.class


BIN
JavaSE/day06/target/classes/com/sf/Person.class


BIN
JavaSE/day06/target/classes/com/sf/Qizong.class


BIN
JavaSE/day06/target/classes/com/sf/Student.class


Some files were not shown because too many files changed in this diff