Spring JDBC package provides a JdbcTemplate and its two brothers SimpleJdbcTemplate and NamedParameterJdbcTemplate.
NamedParameterJdbcTemplate class is based on the JdbcTemplate class, and it is encapsulated to support named parameter feature.
NamedParameterJdbcTemplate mainly provides the following three methods: the execute method, method of query and queryForXXX, update and batchUpdate method.
Example in the
project:
String username = “root”;
String password = “root”;
String driver = “com.mysql.jdbc.driver”;
String url = “JDBC: mysql:// 127.0.0.1:3306/upwis_flow?CharacterEncoding = utf-8 “;
Class.forName(driver);
Connection conn= DriverManager.getConnection(url, username, password);
DataSource dataSource=new SingleConnectionDataSource(conn,false);
NamedParameterJdbcTemplate jdbc=new NamedParameterJdbcTemplate(dataSource);
jdbc.getJdbcTemplate();
List list = jdbc.queryForList("select * from fw_dir",new HashMap<>());
System.out.println(list);
div>
Read More:
- Spring boot thymeleaf crud implements simple functions of adding, deleting, modifying and querying
- Spring initializer error: initialization failed for ‘ https://start.spring.io ‘
- C# SevenZip simple operation
- Simple license plate recognition based on Halcon
- Spring boot problem 1: error reporting life processing instructions for building a spring boot project
- To the brothers who encountered simple bind failed 192.168.1.×××: 636
- Summary of OpenGL simple solar system simulation
- Simple understanding and basic operation of mongodb
- Simple Python crawler exercise: News crawling on sohu.com
- Simple solution for node sass installation failure
- Python data cleaning — delete failed images__ Simple version
- How to empty a whole line in latex (simple and effective)
- Simple configuration of glfw + glad in vs2015 OpenGL development environment
- main.cpp : (. Text + 0xd06): undefined reference to XX method | simple record
- Solution to unbalanced load of multiple cards (GPU’s 0 card is too high) in Python model training (simple and effective)
- A simple method of generating secret key by GIT and configuring SSH public key
- MySQL 8 — error in setting simple password error 1819 (HY000): your password does not satisfy the current policy requirements
- Spring error: ora-01017: invalid username / password; login denied
- In the XML configuration file of spring jdbc.properties The connection to the database failed due to garbled code
- There will be row spacing problems in algorithm use in latex. Please use the ‘setstretch {1.35}