Take accessing a student information table as an example:
First, create the Access database file student.mdb, open the table designer, enter the field name and data type, and set the primary key:
Second, create test data:
num | name | age | fromw | school | major | score | |
---|---|---|---|---|---|---|---|
200706001 | Zhang Fei | 19 | Jilin | Jilin University | Linguistics | 388 | |
200706002 | Liu Bei | 20 | Jilin | Northeast Normal University | Japanese | 328 | |
200706003 | Guan Yu | 19 | Beijing Peking | University | Computer Software and Theory | 421 | |
200706004 | Diao Chan | 18 | Sichuan | Sichuan University | Electronic Information Engineering | 376 | |
200706005 | Guan Hanqing | 18 | Zhejiang | Zhejiang University | Computational Mathematics | 375 | |
200706006 | Quyi | 20 | Zhejiang | Zhejiang University | Applied Chemistry | 402 | |
200706007 | Oman | 19 | Beijing | Peking University | Library Management | 314 | |
200706008 | Apei | 19 | Beijing | Beihang University | Thermal Energy and Power Engineering | 348 | |
200706009 | Wu Zetian | 19 | Shanghai | Fudan University | European and American Literature | 399 | |
200706010 | Liu Yunlong | 18 | Liaoning | Shenyang University of Technology | Mechanical Manufacturing | 416 | |
200706011 | Fang Ge | 19 | Liaoning | Dalian University of Technology | Applied Mathematics | 333 | |
200706012 | Wang Da | 21 | Tianjin | Tianjin University | Network Application | 342 | |
200706013 | Xishi | 18 | Tianjin | Nankai University | Data Warehouse | 411 | |
200706014 | Li Shimin | 18 | Jilin | ChangchunInformation Management | of Polytechnic University | and Information Systems | 364 |
200706015 | Wang Mang | 19 | Hubei | Wuhan University | SolarEnergy | 294 | |
200706016 | Zhu | Yuanzhang | 18 | Hubei | Wuhan University | Geothermal352 | |
200706017 | ZhugeLiang | 19 | Beijing | Tsinghua University | Data Mining Technology | 434 | |
200706018 | Shi Dakai | 20 | Beijing | University of Science and Technology Beijing | Energy Engineering | 319 | |
200706019 | Hong Fengzhu | 18 | Beijing | beijing foreign language University | Foreign Languages and Culture | 347 | |
200706020 | Liu Yan | 18 | Heilongjiang | Harbin Institute of Technology | Electrical Engineering and Automation | 405 | |
" + rst.getInt( " num " ) + " " ); out.println( " | " + rst.getString( " name " ) + " " ); out.println( " | " + rst.getInt( " age " ) + " " ); out.println( " | " + rst.getString( " fromw " ) + " " ); out.println( " | " + rst.getString( " school " ) + " " ); out.println( " | " + rst.getString( " major " ) + " " ); out.println( " | " + rst.getInt( " score " ) + " " ); out.println( " " ); } rst.close(); stmt.close(); con.close(); %> < SPAN> table > center > body > html > Next, set the configuration file in Tomcat 5.5.20: Create a WEB-INF directory in the Student directory, and create a web.xml file in the WEB-INF directory. The configuration content is:
xml version="1.0" encoding="ISO-8859-1" ?> < web-app xmlns ="http://java.sun.com/xml/ns/j2ee" xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation ="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd" version ="2.4" > <display-name> Student display-name > <description> Query the information of students from Access Database description > web-app > Finally, start the Tomcat server and type the following URL in the address bar to access the database Student.mdb: http://127.0.0.1:8080/Student/Student.jsp The access results are as shown in the figure: This achieves access to the Access database.
Related Articles
|