-Java connection to Excel, MySQL, SQLServer data sources and related methods of adding, deleting, modifying, checking and problem summary-[Part III]

[Part III]-Java connection to SQLServer data source and related query, insertion, deletion, update methods and problem summary- 1. Foreword Continuing from [Part II], in projects, we often encounter scenarios where data source data needs to be read and processed. The data source is usually Excel, MySQL , SQLServer. Not long ago, I happened to participate in such a project, which also involved the above three data sources. I also stepped on some pitfalls along the way. Therefore, I feel it is necessary to write a summary. I hope it will be helpful to those who read this article. People can help. 2. Preparation You need to download a jar package – sqljdbc4.jar, and import sqljdbc4.jar into the project through: Build Path -> Configure Build Path -> Add External JARs in Referenced Libraries. Note: The JRE that the sqljdbc4.jar package matches is JDK1.6. If the version does not match, running abnormalities may occur. Related content can be found: Click to open the link (http://blog.csdn.net/teamlet/article/details/52389665) 3. Implementation of query, insertion, deletion and update 3.1 Create connection /** * constructs connection to SQLServer. * @since 2017.03.17 * @author ***** * @return Connection */ public Connection connectToSQLServer() { //Database driver, fixed, but different depending…

-Java connects Excel, MySQL, SQLServer data sources and related methods of adding, deleting, modifying, checking and problem summary-[Part II]

[Part II]-Java connection to Mysql data source and related methods of adding, deleting, modifying, checking and problem summary- 1. Foreword Continuing from [Part I], in projects, we often encounter scenarios where we need to read data from data sources and process them. The data sources are usually Excel, MySQL , SQLServer. Not long ago, I happened to participate in such a project, which also involved the above three data sources. I also stepped on some pitfalls along the way. Therefore, I feel it is necessary to write a summary. I hope it will be helpful to those who read this article. People can help. 2. Preparation You need to download a jar package – mysql.jar, and import mysql.jar into the Referenced Libraries of the project through: Build Path -> Configure Build Path -> Add External JARs . 3. Implementation of query, insertion, deletion and update 3.1 Basic information settings /** * @param args * //localhost:3306 in the URL is the local address and loopback address, because the MySQL service is on the local machine and the java program is also On this machine, * test is a database in MySQL. After specifying it, the tables in it are operated *…

JavaWeb——A case of adding, deleting, modifying and checking under MVC mode

Directory MVC mode Environment configuration pom.xml mybatis-config. xml Directory structure java directory: com directory: mapper directory: pojo directory: service directory: util directory: web directory&#xff1a ; resources directory: com/mapper directory: BrandMapper.xml webapp directory&# xff1a; index.html brand.jsp addBrand.jsp updateBrand.jsp MVC mode Environment configuration pom.xml 4.0.0com.myprojectbrand-demo1.0-SNAPSHOTwarmysqlmysql-connector-java8.0.21org.mybatismybatis 3.4.6javax.servletjavax.servlet-api3.1.0provided org.apache.mavenmaven-plugin-api2.0 commons-iocommons-io2.6javax.servlet.jspjsp-api2.1providedjstljstl1.2 org.apache.tomcat.maventomcat7-maven-plugin2.2 mybatis-config.xml Directory structure java directory: com directory: mapper directory: package com.mapper;import com.pojo.Brand;import java.util.List;public interface BrandMapper {List selectAll();void add(Brand brand);Brand selectById(int id);void update(Brand brand);void deletet(int id);} pojo directory: package com.pojo;/*** Brand entity class*/public class Brand {// id primary key private Integer id; // Brand name private String brandName; // Company name private String companyName; // Sorting field private Integer ordered; // Description information private String description; // Status :0:Disabled 1:Enable private Integer status;public Brand() {}public Brand(Integer id, String brandName, String companyName, String description) {this.id = id;this.brandName = brandName;this .companyName = companyName;this.description = description;} public Brand(Integer id, String brandName, String companyName, Integer ordered, String description, Integer status) {this.id = id;this .brandName = brandName;this.companyName = companyName;this.ordered = ordered;this.description = description;this.status = status;}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getBrandName() {return brandName;}public void setBrandName(String brandName) {this.brandName = brandName;}public String getCompanyName() {return companyName;}public void setCompanyName(String companyName) {this.companyName = companyName;}public Integer getOrdered() {return ordered;}public…

Java program to realize class grabbing_Please use JAVA to write a simple course selection system program for me to realize the functions of adding, deleting, modifying and checking…

This floor is suspected of violating the rules and has been folded by the system. Hide this floor and view this floor I have already written the SQL script – please help me. –Create database student create database student go –Use database use student go –Create student information table create table stuInfo ( sno char(11 ) not null check(sno like '513%') primary key, sname char(8) not null, sex char(2) not null check(sex in ('Male','Female')), age int not null check(age between 18 and 50) default(18) , class char(4) not null, nation char(10) not null ) go –Create course information table create table course ( cid int not null check(cid between 1 and 100) primary key, cname char(10) not null unique, ct int not null check(ct between 1 and 200), tscore int not null default(100) , mark varchar(50) ) go –Create student course selection table create table sc ( sno char(11) not null, cid int not null, score float not null default( 0) ) go –add constraints –joint primary key alter table sc add constraint PK_sc primary key(sno,cid) go –add foreign key+cascade alter table sc add constraint FK_sno foreign key(sno) references stuInfo(sno) on delete cascade on update cascade go alter table sc…

Java link database, as well as the toolkit for adding, deleting, checking and modifying  --Source code [MySQL]

Java linked database, and toolkit for adding, deleting, checking and modifying – source code [MySQL]

Database | mysql tutorial Database-mysql tutorial comment page html source code, Ubuntu18efi, how to uninstall tomcat9 , the source code of the crawler, the source code of PHP playing Youku video, Shannan seo tutorial lzwpackage com.msit.util; web account recharge source code, how to use vscode git, automatic ip ubuntu, how to completely close tomcat, sqlite database suffix name, crawler text , php adds text to pictures, how much does Loudi seo optimization cost, thinkphp novel website template, electronic chapter template psdlzwimport java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement; import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;asp read and write txt file source code, vscode plug-in logical symbols, create thread Ubuntu, tomcat Image mapping configuration, sqlite3 view table name, basic principles of web crawler courseware video, PHP syntax detection, Jiangjin District SEO optimization plan, what are the web template websites, how to modify the homepage template folder of Empire CMS lzw/** * Database Tool class links MySql database * * @author Administrator * */public class SqlHelper { // The data required for the link (these data Write directly to the encrypted data file). private static String url = “jdbc:mysql://127.0.0.1:3306/msitdb”; private static String user = “root”; private static String password = “root” ; private static String driverName = “com.mysql.jdbc.Driver”; //…

MVC design pattern ((javaWEB) implements operations of adding, deleting, modifying and checking data in the database under the database connection pool)…

MVC design pattern ((javaWEB) implements operations of adding, deleting, modifying and checking data in the database under the database connection pool)…

Implementation of design function: —-There is no business layer,The DAO is directly called by the Servlet, so there is no transaction operation,So it is obtained directly from the DAO connection object —-Adopt MVC design pattern —-Adopt technology . MVC design pattern,JSP,Servlet,POJO . The database uses mysql . The database connection pool requires the use of C3P0 database connection pool . The prompts on the page require the use of jQuery —-Technical difficulties  . How to use a Servlet for multiple requests . How to fuzzy query . How to “verify whether user information has been used” and give prompts when creating and modifying ——— ————————————————– —————————————- 1. First of all Some implementations of database connection pool C3P0 need to import five open source framework packages: c3p0-0.9.1.2.jar commons-dbcp-1.4.jar commons-dbutils-1.3.jar commons-pool-1.5.5.jar mysql-connector-java-5.1.6-bin.jar ————————————————- ————————– 2. The file to connect to the database connection pool is : Create an XML file c3p0-config.xml in the src directory;    root  lxn123 com.mysql.jdbc.Driver  jdbc:mysql:///test  5  10  10  50    20  5   ———————————————— ———————————- 3. Classes for connecting to the database connection pool&# xff1a;JdbcUtils public class JdbcUtils {  //Release connection connection  public static void releaseConnection(Connection connection){   try { if (connection!=null) {     connection.close();    }    } catch (Exception e) {…

Java simply implements the method of adding, deleting, modifying and checking arrays_java

Catalogue 1. One-dimensional array 2. Array expansion 3. Copy of array 1. Directly assign the array to the new array 2. Create a new array, and then assign the data of the original array one by one 4. Deletion of array 5. Sorting of arrays 6. Array search 1. Sequential search: traverse from beginning to end (simple elimination, relatively low efficiency) 2. Binary search Summary 1. One-dimensional array Concept: a container for a set of data (an array can store multiple data) ​ Note: ​ 1. Arrays are reference data types ​ 2. The data in the array is also called elements ​ 3. Each element has a number called a subscript/index ​ 4. The subscript starts from 0 ​ 5. After the array is initialized, a series of continuous spaces will be opened in the memory ​ 6. Once the array is initialized, the length cannot be changed (the array is not expanded or deleted) ​ 7. Array operations: add, modify, query​ ​ Array declaration: data type [] array name;​ Initialization of array: ​ Static initialization: data is specified by the programmer, and length is allocated by the system public static void main(String[] args){ //Static initialization 1 //String[] names…

JAVAWEB realizes the modification function of adding, deleting, checking and modifying (book information management)

JAVAWEB realizes the modification function of adding, deleting, checking and modifying (book information management)

 First, click the modify button on the index.jsp page to get the id of the row: ↓ Secondly, jump to the updateBooks.jsp page to modify the information. The page code is as follows: ↓ 1 <%– 2 Created by IntelliJ IDEA. 3 User: NFS 4 Date: 2019-7-12 5 Time: 14:31 6 To change this template use File | Settings | File Templates. 7 –%> 8 9 10 11 12 13 14 15 <% 16 Books books = (Books) request.getAttribute(“update”);17 18 if (books != null) {19 %>20 21 22 23 24 Number:25 <input name="book_id" value="” readonly> 26 27 28 Book title:29 <input name="book_name" value="”>30 31 32 Author:33 <input name="author" value="”>34 35 36 Inventory:37 <input name="number" value= "”>38 39 40 Price:41 <input name=" price" value="”>42 43 44 Publisher:45 <input name="pub" value="”>46 47 48 49 50 51 <%52 } else {53 %>54 No relevant data was found for this ID, so it cannot be modified. 55 <%56 }57 %>58 59 60 61 /books/lst”>Return to homepage62 63 64   The servlet corresponding to updateBooks.jsp: updateBooks.java, the code is as follows: ↓ 1 package BookSystem.CRUD; 2 3 import BookSystem.Other.Books; 4 import BookSystem.Other.DButil; 5 6 import javax.servlet.ServletException; 7 import javax.servlet.annotation.WebServlet; 8 import javax.servlet.http.HttpServlet; 9 import javax.servlet.http.HttpServletRequest;…

JavaEE_The idea of ​​adding, deleting, checking and modifying

Add Write a piece of data to the database. Delete Delete data from the database by unique identifier. Query Query the data according to the specified conditions. Change Query first, What is displayed on the page is The queried data is modified and the data is written back to the database.

A class in JavaScript that facilitates adding, deleting, and modifying cookies

The function is assembled mainly by analyzing the document.COOKIE string. Review the operation of COOKIE in Javascript: Increasing COOKIE can be achieved by using document.COOKIE=”userId=111″;The full version can be Use: document.COOKIE=”userId=111;domain=.google.com;path=\;secure=secure;expire=”+date.toGMTString(); You can set the expiration time of COOKIE , domain name, pathIf you need to delete it, just set the expire time to before nowNow the Javascript.COOKIE.js class I modified The call is also quite simple

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索