From dd6fd583ff7285e51c5b81edaa7df9f530fc7707 Mon Sep 17 00:00:00 2001 From: zhangqingqing Date: Mon, 21 Apr 2025 14:54:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 +++ .idea/compiler.xml | 13 ++++ .idea/encodings.xml | 7 ++ .idea/jarRepositories.xml | 20 ++++++ .idea/misc.xml | 14 ++++ .idea/modules.xml | 8 +++ .idea/spring20250421.iml | 9 +++ .idea/vcs.xml | 6 ++ springLearn202503/pom.xml | 45 ++++++++++++ .../src/main/java/com/sec/Main.java | 65 ++++++++++++++++++ .../src/main/java/com/sec/dao/UserDao.java | 5 ++ .../java/com/sec/dao/impl/UserDaoImpl.java | 23 +++++++ .../java/com/sec/factroy/DemoFactroy.java | 11 +++ .../java/com/sec/factroy/StaticFactroy.java | 10 +++ .../src/main/resources/application.xml | 9 +++ .../target/classes/application.xml | 9 +++ .../target/classes/com/sec/Main.class | Bin 0 -> 3418 bytes .../target/classes/com/sec/dao/UserDao.class | Bin 0 -> 131 bytes .../com/sec/dao/impl/UserDaoImpl.class | Bin 0 -> 776 bytes .../classes/com/sec/factroy/DemoFactroy.class | Bin 0 -> 428 bytes .../com/sec/factroy/StaticFactroy.class | Bin 0 -> 420 bytes 21 files changed, 262 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/spring20250421.iml create mode 100644 .idea/vcs.xml create mode 100644 springLearn202503/pom.xml create mode 100644 springLearn202503/src/main/java/com/sec/Main.java create mode 100644 springLearn202503/src/main/java/com/sec/dao/UserDao.java create mode 100644 springLearn202503/src/main/java/com/sec/dao/impl/UserDaoImpl.java create mode 100644 springLearn202503/src/main/java/com/sec/factroy/DemoFactroy.java create mode 100644 springLearn202503/src/main/java/com/sec/factroy/StaticFactroy.java create mode 100644 springLearn202503/src/main/resources/application.xml create mode 100644 springLearn202503/target/classes/application.xml create mode 100644 springLearn202503/target/classes/com/sec/Main.class create mode 100644 springLearn202503/target/classes/com/sec/dao/UserDao.class create mode 100644 springLearn202503/target/classes/com/sec/dao/impl/UserDaoImpl.class create mode 100644 springLearn202503/target/classes/com/sec/factroy/DemoFactroy.class create mode 100644 springLearn202503/target/classes/com/sec/factroy/StaticFactroy.class diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.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 diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..7ca1f95 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..0796e1b --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0a83112 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b5bb779 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/spring20250421.iml b/.idea/spring20250421.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/spring20250421.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/springLearn202503/pom.xml b/springLearn202503/pom.xml new file mode 100644 index 0000000..4c8bece --- /dev/null +++ b/springLearn202503/pom.xml @@ -0,0 +1,45 @@ + + + 4.0.0 + + com.sec + springLearn202503 + 1.0-SNAPSHOT + + + 8 + 8 + UTF-8 + + + + + org.springframework + spring-context + 5.3.21 + + + junit + junit + 4.13.2 + + + + mysql + mysql-connector-java + 8.0.23 + + + com.alibaba + druid + 1.1.22 + + + com.mchange + c3p0 + 0.9.5.4 + + + \ No newline at end of file diff --git a/springLearn202503/src/main/java/com/sec/Main.java b/springLearn202503/src/main/java/com/sec/Main.java new file mode 100644 index 0000000..7ef5b8e --- /dev/null +++ b/springLearn202503/src/main/java/com/sec/Main.java @@ -0,0 +1,65 @@ +package com.sec; + +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.pool.DruidPooledConnection; +import com.mchange.v2.c3p0.ComboPooledDataSource; +import com.sec.dao.UserDao; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import java.beans.PropertyVetoException; +import java.sql.*; + +//TIP To Run code, press or +// click the icon in the gutter. +public class Main { + public static void main(String[] args) { +// ApplicationContext application=new ClassPathXmlApplicationContext("application.xml"); + ClassPathXmlApplicationContext application=new ClassPathXmlApplicationContext("application.xml"); + UserDao userDao1 = (UserDao)application.getBean("UserDao"); +// UserDao userDao2 = (UserDao)application.getBean("UserDao"); + System.out.println(userDao1); + application.close(); +// System.out.println(userDao2); + +// userDao.getData(); + DruidDataSource druidDataSource=new DruidDataSource(); + druidDataSource.setDriverClassName("com.mysql.jdbc.Driver"); + druidDataSource.setUrl("jdbc:mysql://47.103.155.22:3306/learn_spring"); + druidDataSource.setUsername("root"); + druidDataSource.setPassword("mysql_wafeYX"); + + try { + DruidPooledConnection connection = druidDataSource.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement(" select * from user_info "); + ResultSet resultSet = preparedStatement.executeQuery(); + while (resultSet.next()) { + System.out.println(resultSet.getString("user_name")+" "+resultSet.getString("account_name")); +// System.out.println(resultSet.getString("account_name")); + } + resultSet.close(); + preparedStatement.close(); + connection.close(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + ComboPooledDataSource comboPooledDataSource=new ComboPooledDataSource(); + try { + comboPooledDataSource.setDriverClass("com.mysql.jdbc.Driver"); + comboPooledDataSource.setJdbcUrl("jdbc:mysql://47.103.155.22:3306/learn_spring"); + comboPooledDataSource.setUser("root"); + comboPooledDataSource.setPassword("mysql_wafeYX"); + + Connection connection = comboPooledDataSource.getConnection(); + Statement statement = connection.createStatement(); + ResultSet resultSet = statement.executeQuery("select * from user_info "); + while (resultSet.next()) { + System.out.println(resultSet.getString("user_name")); + } + statement.close(); + connection.close(); + } catch (PropertyVetoException | SQLException e) { + throw new RuntimeException(e); + } + + } +} \ No newline at end of file diff --git a/springLearn202503/src/main/java/com/sec/dao/UserDao.java b/springLearn202503/src/main/java/com/sec/dao/UserDao.java new file mode 100644 index 0000000..2e10663 --- /dev/null +++ b/springLearn202503/src/main/java/com/sec/dao/UserDao.java @@ -0,0 +1,5 @@ +package com.sec.dao; + +public interface UserDao { + public void getData(); +} diff --git a/springLearn202503/src/main/java/com/sec/dao/impl/UserDaoImpl.java b/springLearn202503/src/main/java/com/sec/dao/impl/UserDaoImpl.java new file mode 100644 index 0000000..d04a22e --- /dev/null +++ b/springLearn202503/src/main/java/com/sec/dao/impl/UserDaoImpl.java @@ -0,0 +1,23 @@ +package com.sec.dao.impl; + +import com.sec.dao.UserDao; + +public class UserDaoImpl implements UserDao { + + public UserDaoImpl(){ + System.out.println("无参构造"); + } + + public void init(){ + System.out.println("初始化方法"); + } + + public void destroy(){ + System.out.println("销毁方法"); + } + + @Override + public void getData() { + System.out.println("hello user!!!"); + } +} diff --git a/springLearn202503/src/main/java/com/sec/factroy/DemoFactroy.java b/springLearn202503/src/main/java/com/sec/factroy/DemoFactroy.java new file mode 100644 index 0000000..56cce30 --- /dev/null +++ b/springLearn202503/src/main/java/com/sec/factroy/DemoFactroy.java @@ -0,0 +1,11 @@ +package com.sec.factroy; + +import com.sec.dao.UserDao; +import com.sec.dao.impl.UserDaoImpl; + +public class DemoFactroy +{ + public UserDao getDao(){ + return new UserDaoImpl(); + } +} diff --git a/springLearn202503/src/main/java/com/sec/factroy/StaticFactroy.java b/springLearn202503/src/main/java/com/sec/factroy/StaticFactroy.java new file mode 100644 index 0000000..a7faf68 --- /dev/null +++ b/springLearn202503/src/main/java/com/sec/factroy/StaticFactroy.java @@ -0,0 +1,10 @@ +package com.sec.factroy; + +import com.sec.dao.UserDao; +import com.sec.dao.impl.UserDaoImpl; + +public class StaticFactroy { + public static UserDao getUserDao() { + return new UserDaoImpl(); + } +} diff --git a/springLearn202503/src/main/resources/application.xml b/springLearn202503/src/main/resources/application.xml new file mode 100644 index 0000000..07e16a7 --- /dev/null +++ b/springLearn202503/src/main/resources/application.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/springLearn202503/target/classes/application.xml b/springLearn202503/target/classes/application.xml new file mode 100644 index 0000000..07e16a7 --- /dev/null +++ b/springLearn202503/target/classes/application.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/springLearn202503/target/classes/com/sec/Main.class b/springLearn202503/target/classes/com/sec/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..673f08959715ecdfe8f6196111ec6ba25564b0cf GIT binary patch literal 3418 zcmbtXS#%p$8UDtRePwA9C#s!BS*V(n#EvbEm!yl61`@jkisL$Q65`80<%%f#n1vfiVJGLDB!dsk3tMCii$EX;KdNfOcW)x`%#qDekqE} zYF~(AQSBd8%ZH-)a10;8N8|VyJ|4#>@JWGB#jsPUKcU_~tzJG8#b=}VoO=Aca`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igDn^qNl}fhi?Jm|Jt%trhw?rY zdOxH=Ic^Ocw<^asu!#^}C3!z?YJ0R44p;a6sCGSL< zZ$sG4{OzHY6dqz`$FUdh!9JMOdx}!eq8nHE$$S-k^l}i_(aQ;+#!Y7XRrKRE4B&4V z#NYY*;B|U`gSGJ{tK(m|U+cgTZ99%?w9d#L)b`?-*2jdaLU;n3>2Dgxae|2-$2p8( z6s`1qlJtjJG}jsPJMd0&UuUr#$GgaVgB~8iyUBf%u_!q~t4eN+TowXX!CQZ$J^zRXzxT^8!->j|n_3@LqxU3A`V8V3mkP onwii9rsJ!GEZR&K_<(>ZkPXy!tzs)$*YTC66=zgA`fY*y53{|Ul>h($ literal 0 HcmV?d00001 diff --git a/springLearn202503/target/classes/com/sec/dao/UserDao.class b/springLearn202503/target/classes/com/sec/dao/UserDao.class new file mode 100644 index 0000000000000000000000000000000000000000..e9733266d329b8a6564b57a00e6494ba9727fa3f GIT binary patch literal 131 zcmX^0Z`VEs1_l!bPId-%b_Nbc2KMyS5|_l1L`DW?4b3n{2Cm@z(xT*4x6GVWMh2eH z;?yFS#C*N1#4?}?;pF^W{o>SQ{glLfeW(;8g8)cUKPNFSUEe<`D>b=-!G?SJAG*!f^{HaMHx7 zDo$g;#2FKdCYB5=8*mJq6_~p2M}B%kpxkQr1S+@mKncur{7Bs$g?$x2ko|y}xsLW^ z(37#B$CG3wUGo!x#g3;#H&LEDklOXbjlg}FsCZTCJAAK@n)eVe1}aHoy~)>5rK>WP z0@bb_#h$wD=S}JdWLMVZBWdF(Yy;KwzKVT+2_|R+Q0^~OQP z#O0yF?q-szkYm&%mNz?l2w%JRV?Ro}X{=<(K{N`|oW@386hzdu{s{MaQ{_j)m39vf zOfHkd;$|znITW5XMmJI73#eWG3h@c0x$+lOJ~C0lG|y?2c^VX%lvtQyluIc<9kaZ- z*?rix3CzktM-G9i{K};!h5sPdKBQ3$nJR$P37IW~94m$x1&}5o^M#NmeU>o)8@d{t A`2YX_ literal 0 HcmV?d00001 diff --git a/springLearn202503/target/classes/com/sec/factroy/DemoFactroy.class b/springLearn202503/target/classes/com/sec/factroy/DemoFactroy.class new file mode 100644 index 0000000000000000000000000000000000000000..10a57dbdb9e2c56a7f75ebf87fd4c408c74f4daa GIT binary patch literal 428 zcmZut!AiqG5Ph4bNgAuIRq>!6ytN)&5O0bXOF;;FPzxS6=~}lW*^;D!f2F5_f*;^V ziL7wJqGI`6zHiL7nQdL|q)VjSPgMFz-lA#r- zR9?@LP-b@`jH%NJbR^=T$dsvnn|AS}a)yH-(h1LH#2-aeWcr2oWugZQd`3IQvgixV zu-ok|sUxBJeJ(Q^5XHaMvn-MWWp=e!Q)ZOwM{}^Za@?TkluZXd;pT#XH9{b~jtz=N cd{UYL-UqCQIcl%ev+$>HtmwU^zE!f?KbBTkU;qFB literal 0 HcmV?d00001 diff --git a/springLearn202503/target/classes/com/sec/factroy/StaticFactroy.class b/springLearn202503/target/classes/com/sec/factroy/StaticFactroy.class new file mode 100644 index 0000000000000000000000000000000000000000..c426d2a67e835b2156f4e71ac371d30f094db391 GIT binary patch literal 420 zcmZut!A=4(5Ph@2F03es8ZR341|ICio5qWV#DwSpCGl8F#gc`R-D2Wj>4`)WKfsSN zPJuNsv4@%W-pre6=Ii_Y6Tm5UVwA8Mp%EkSc`L#;Av`w|<1Pq=W~)aiUfO{s)H-IO zZ)W4ZPVZztVWrWrN+vy-8qZf^(LI@raL`e9EHbUcqf{=nFQV(DGpfC0XM}jD-F>Fh zD`^S4&DO7BAgx#xd|TJfQl;BwvGLE4laYLuRfLELd-*!=HsfiMkGN(`*w4%V{)SNZ zqeLPnLvh<5Y2|Q)BHzZp0DKZe9LvlEXX0Eso`c>Ny!kFEgt#3sC<7W-ME8 literal 0 HcmV?d00001