Step 3 of JSP environment setup and MYSQL Installation
1) install MYSQL
- [root@linuxas Server]# rpm -vih perl-DBI-1.52-1.fc6.i386.rpm
- warning: perl-DBI-1.52-1.fc6.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
- Preparing... ########################################### [100%]
- 1:perl-DBI ########################################### [100%]
- [root@linuxas Server]# rpm -vih mysql-5.0.22-2.1.i386.rpm
- warning: mysql-5.0.22-2.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
- Preparing... ########################################### [100%]
- 1:mysql ########################################### [100%]
- [root@linuxas Server]# rpm -vih perl-DBD-MySQL-3.0007-1.fc6.i386.rpm
- warning: perl-DBD-MySQL-3.0007-1.fc6.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
- Preparing... ########################################### [100%]
- 1:perl-DBD-MySQL ########################################### [100%]
- [root@linuxas Server]# rpm -vih mysql-server-5.0.22-2.1.i386.rpm
- warning: mysql-server-5.0.22-2.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
- Preparing... ########################################### [100%]
- 1:mysql-server ########################################### [100%]
2) start the service
- [root@linuxas ~]# service mysqld start
Initialize the MySQL database:
- Installing all prepared tables
- Fill help tables
- To start mysqld at boot time you have to copy support-files/mysql.server
- to the right place for your system
- PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
- To do so, start the server, then issue the following commands:
- /usr/bin/mysqladmin -u root password 'new-password'
- /usr/bin/mysqladmin -u root -h linuxas password 'new-password'
- See the manual for more instructions.
- You can start the MySQL daemon with:
- cd /usr ; /usr/bin/mysqld_safe &
- You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
- cd sql-bench ; perl run-all-tests
- Please report any problems with the /usr/bin/mysqlbug script!
- The latest information about MySQL is available on the web at
- http://www.mysql.com
- Support MySQL by buying support/licenses at http://shop.mysql.com
[OK]
Start MySQL: [OK]
Set the username and password for logging on to MySQL
- [root@linuxas ~]# mysqladmin -uroot password pwd@123
Run mysql and grant the root user the remote access permission. For debugging
- use mysql
- update user set host = '%' where user = 'root' and host < > 'localhost';
- flush privileges;
- quit
Step 4 of JSP environment setup and JDBC Installation
1) download the installation process token from the official website.
2) install JDBC and configure tomcat
- [root@linuxas src]# tar -zxvf mysql-connector-java-5.1.7.tar.gz
- [root@linuxas src]# cp mysql-connector-java-5.1.7/mysql-connector-java-5.1.7-bin.jar /tomcat/lib/
- [root@linuxas src]# cp mysql-connector-java-5.1.7/mysql-connector-java-5.1.7-bin.jar /usr/local/src/jdk1.6.0_14/jre/lib/
Step 5: establish the JSP environment and test the system environment
1) Create a database and a table
- mysql> GRANT ALL PRIVILEGES ON *.* TO llk726@localhost IDENTIFIED BY 'pwd@123' WITH GRANT OPTION;
- mysql> create database test;
- mysql> use test;
- mysql> create table testtable(id int not null auto_increment primary key, foo varchar(25), bar int);
- mysql> insert into testtable values(null, 'hello', 12345);
2) compile test. jsp
- [Root @ linuxas ROOT] # vi test. jsp
- <% @ PageContentType="Text/html; charset = gb2312" Language="Java"%>
- <% @ PageImport="Java. SQL .*"%>
- <%
- Class. forName ("com. mysql. jdbc. Driver"). newInstance ();
- StringUrl="Jdbc: mysql: // localhost/test? User = llk726 & password = pwd @ 123 & useUnicode = true & characterEncoding = utf8";
- ConnectionConn=DriverManager. GetConnection (url );
- StatementStmt=Conn. CreateStatement (ResultSet. TYPE_SCROLL_SENSITIVE, ResultSet. CONCUR_UPDATABLE );
- StringSQL="Select * from testtable";
- %>
- < Table Border=1>
- < Tr>
- < Td>Field 1</Td>
- < Td>Field 2</Td>
- < Td>Field 3</Td>
- </Tr>
- <%
- ResultSetRs=Stmt. ExecuteQuery (SQL );
- While (rs. next () {%>
- < Tr>
- < Td><% = Rs. getString ("ID") %> </Td>
- < Td><% = Rs. getString ("FOO") %> </Td>
- < Td><% = Rs. getString ("BAR") %> </Td>
- </Tr>
- <%} %>
- </Table>
- <% Rs. close ();
- Stmt. close ();
- Conn. close ();
- %>
3) the test results are as follows:
The JSP running environment is successfully established. This article is from the "keyboard is life" blog.
- JDK installation and Tomcat configuration for JSP environment setup
- Discussion on how to implement the componentization of JSP image uploading
- Introduction to using jspsmart for file upload and download
- Use JSP pages to generate PDF reports
- Step for customizing JSP labels