JavaWeb

service生命周期

//loadOnStartup默认值是-1,0或者正整数,服务器创建时启动serblet对象,数字越小优先级越高 package DemoServlet; import javax.jws.WebService; import javax.servlet.*; import javax.servlet.annotation.WebServlet; import java.io.IOExceptio...

Tomcat插件配置

<plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration>...

动态删除

<delete id=”del”> <!–删除一个 DELETE FROM tb_brand where id = #{id};–> DELETE FROM tb_brand where id in <foreach collection=”array” item=”id” separator=”,” open=”(” close=”)”> #{id} &l...

动态条件查询

多条件查询 第一种方法: <select id=”dim” resultType=”DimDyl.Demo05.Dio”> select * from tb_brand where 1 = 1 <if test=”id != null”> and id = #{id} </if> <if test=”Pp_ename != null and Pp_enam...

Mapper代理_多条件查询

<select id=”dim” resultType=”DimDyl.Demo05.Dio”> select * from tb_brand where id = #{id} and Pp_ename like #{Pp_ename} and Qy_ename like #{Qy_ename}; </select> //散装参数 //List<Dio> dim...

Mapper代理_查询详情

//加载mybatis核心文件 String resoures = “mybatis-config.xml”; InputStream resourceAsStream = Resources.getResourceAsStream(resoures); SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(...

Mapper代理开发

//加载mybatis核心文件 String resoures = “mybatis-config.xml”; InputStream resourceAsStream = Resources.getResourceAsStream(resoures); SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(...

MyBatis快速入门

//加载mybatis核心文件,获取SqlSessionFactory String resource = “mybatis-config.xml”; InputStream inputStream = Resources.getResourceAsStream(resource); SqlSessionFactory sqlSessionFactory = new SqlSessionFacto...

Maven依赖管理

Maven查找包:https://mvnrepository.com/ 多个导入项目只能在一个dependencies中创建,不然会报错 <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version...

Maven基本使用

配置阿里云仓库 //settings.xml <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> <mirrorOf>cen...

druid的使用

//获取连接 String url = “jdbc:mysql:///xuexi”; String user = “root”; String passwd = “123321”; Connection cnt = DriverManager.getConnection(url, user, passwd); //加载配置文件 Properties prop = new Properties();...

druid连接池配置文件(druid.properties)

driverClassName=com.mysql.cj.jdbc.Driver #URL连接数据库的URL,其中travel(以下面例子来说)为连接的数据库,后面的参数可不改但不删 url=jdbc:mysql://localhost:3306/travel?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC ...

preparedStatement防止SQL注入

String url = “jdbc:mysql:///xuexi”; String user = “root”; String passwd = “123321”; Connection connection = DriverManager.getConnection(url, user, passwd); Statement statement = connection.createState...

ResultSet

public static void main(String[] args) throws Exception{ dim(); } public static void dim() throws Exception{ String url = “jdbc:mysql:///xuexi”; String user = “root”; String passwd = “123321”; Connect...

connection&statement

//获取连接 String url = “jdbc:mysql:///xuexi”; String user = “root”; String passwd = “123321”; Connection connection = DriverManager.getConnection(url,user,passwd); Statement statement = connection.create...

JDBC连接数据库

import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; public class Mian { public static void main(String[] args) throws Exception{ //注册驱动 //Class.forName(“com.mysql.jdb...