YouTip LogoYouTip

Jsp Database Access

-- Learning not just technology, but dreams! Home HTML JAVASCRIPT CSS VUE REACT PYTHON3 JAVA C C++ C# AI GO SQL LINUX VS CODE BOOTSTRAP GIT Local Bookmarks JSP Tutorial JSP Tutorial JSP Introduction JSP Development Environment Setup Eclipse JSP/Servlet JSP Structure JSP Lifecycle JSP Syntax JSP Directives JSP Action Elements JSP Implicit Objects JSP Client Request JSP Server Response JSP HTTP Status Codes JSP Form Processing JSP Filters JSP Cookie Handling JSP Session JSP File Upload JSP Date Processing JSP Page Redirection JSP Hit Counter JSP Auto Refresh JSP Send Email JSP Advanced Tutorial JSP Standard Tag Library (JSTL) JSP Database Connection JSP XML Data Processing JSP JavaBean JSP Custom Tags JSP Expression Language JSP Exception Handling JSP Debugging JSP Internationalization JSP Standard Tag Library (JSTL) JSP XML Data Processing Deep Dive Scripting Languages Programming Web Service Development Tools Scripts Programming Languages Computer Science Software Web Services Web Design and Development JSP Database Connection This tutorial assumes you already understand how JDBC applications work. Before you start learning about JSP database access, please visit Java MySQL Connection to set up the relevant driver and configuration. Note: You can download the jar package provided by this site: MySQL 5 version: mysql-connector-java-5.1.39-bin.jar MySQL 8 version: mysql-connector-java-8.0.19.jar After downloading, copy mysql-connector-java--bin.jar to the lib directory under tomcat. Database connections for MySQL 8.0 and above are different: 1. com.mysql.jdbc.Driver is replaced by com.mysql.cj.jdbc.Driver. MySQL 8.0 and above versions do not require establishing an SSL connection; it needs to be explicitly disabled. Finally, you also need to set the serverTimezone. The driver loading and database connection method is as follows: Starting with the basic concepts, let's create a simple table and insert a few records into it. Creating Test Data Next, we will create the TUTORIAL database in MySQL and create the websites table with the following structure: CREATE TABLE `websites` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` char(20) NOT NULL DEFAULT '' COMMENT 'Site Name', `url` varchar(255) NOT NULL DEFAULT '', `alexa` int(11) NOT NULL DEFAULT '0' COMMENT 'Alexa Ranking', `country` char(10) NOT NULL DEFAULT '' COMMENT 'Country', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; Insert some data: INSERT INTO `websites` VALUES ('1', 'Google', 'https://www.google.cm/', '1', 'USA'), ('2', 'Taobao', 'https://www.taobao.com/', '13', 'CN'), ('3', 'Tutorial', ' '5892', ''), ('4', 'Weibo', 'http://weibo.com/', '20', 'CN'), ('5', 'Facebook', 'https://www.facebook.com/', '3', 'USA'); The data table is displayed as follows: SELECT Operation The following example shows how to use JSTL SQL tags to run SQL SELECT statements: SELECT Operation SELECT * from websites;

JSP Database Example -

ID Site Name Site URL
Access this JSP example, and the running result is as follows: INSERT Operation This example shows how to use JSTL SQL tags to run SQL INSERT statements: SELECT Operation INSERT INTO websites (name,url,alexa,country) VALUES ('Tutorial Mobile', ' 5093, 'CN'); SELECT * from websites;

JSP Database Example -

ID Site Name Site URL
Access this JSP example, and the running result is as follows: DELETE Operation This example shows how to use JSTL SQL tags to run SQL DELETE statements: SELECT Operation DELETE FROM websites WHERE Id = ? SELECT * from websites;

JSP Database Example -

ID Site Name Site URL
Access this JSP example, and the running result is as follows: UPDATE Operation This example shows how to use JSTL SQL tags to run SQL UPDATE statements: SELECT Operation UPDATE websites SET name = 'TUTORIAL' WHERE Id = ? SELECT * from websites;

JSP Database Example -

ID Site Name Site URL
Access this JSP example, and the running result is as follows: JSP Standard Tag Library (JSTL) JSP XML Data Processing ByteArk Coding Plan Supports mainstream large models like Doubao, GLM, DeepSeek, Kimi, MiniMax, officially supplied, stable and reliable. Configuration Guide ¥9.9 / Month Subscribe Now iFlytek Spark Coding Plan Includes free model call quota, DeepSeek, GLM, Kimi, MiniMax, one-stop experience and deployment platform. Configuration Guide ¥3.9 / Month Subscribe Now 2 Notes Write Note Scarf Morning 116***2584@qq.com Reference Address 95 java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Confirm that the package has been imported into the web project directory. It turned out that Tomcat couldn't find the MySQL JAR package. Later, I imported mysql-connector-java-5.1.7-bin.jar into the lib directory under Tomcat, and it was okay, heh... In a Java project, you only need to import mysql-connector-java-5.1.7-bin.jar to run the Java project. In a web project, when Class.forName("om.mysql.jdbc.Driver"); is executed, MyEclipse does not search the string or look for the driver. So you just need to copy mysql-connector-java-5.1.7-bin.jar to the lib directory under Tomcat. Scarf Morning Scarf Morning 116***2584@qq.com Reference Address 8 years ago (2018-11-20) Being jic***9@126.com 39 mysql8.0.19 version using connector-5.1.7 will report an error, need to change to mysql-connector-java-8.0.19.jar version, modify JDBC driver name and URL: Being Being jic***9@126.com 6 years ago (2020-05-12) Category Navigation Python / Data Science AI / Intelligent Development Front-end Development Back-end Development Database Mobile Development DevOps / Engineering Programming Languages Computer Fundamentals XML / Web Service .NET Website Construction Advertisement JSP Tutorial JSP Tutorial JSP Introduction JSP Development Environment Setup Eclipse JSP/Servlet JSP Structure JSP Lifecycle JSP Syntax JSP Directives JSP Action Elements JSP Implicit Objects JSP Client Request JSP Server Response JSP HTTP Status Codes JSP Form Processing JSP Filters JSP Cookie Handling JSP Session JSP File Upload JSP Date Processing JSP Page Redirection JSP Hit Counter JSP Auto Refresh JSP Send Email JSP Advanced Tutorial JSP Standard Tag Library (JSTL) JSP Database Connection JSP XML Data Processing JSP JavaBean JSP Custom Tags JSP Expression Language JSP Exception Handling JSP Debugging JSP Internationalization Online Examples ·HTML Examples ·CSS Examples ·JavaScript Examples ·Ajax Examples ·jQuery Examples ·XML Examples ·Java Examples Character Sets & Tools · HTML Character Set Settings · HTML ASCII Character Set · JS Obfuscation/Encryption · PNG/JPEG Image Compression · HTML Color Picker · JSON Formatting Tool · Random Number Generator Latest Updates · AI Introduction Tutorial · Large Model Multimodal (M... · Codex Advanced Configuration · AI Agent Terminology · ZCode Introduction Tutorial · Loop Engineerin... · Claude Code Use... Site Information · Feedback · Disclaimer · About Us · Article Archive Follow WeChat My Favorites Mark Article Browsing History Clear All No Records
← Jsp Xml DataJsp Jstl →