乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      linux 下 jdk+tomcat+mysql 的 jsp 環(huán)境搭建

       憂郁_小剛 2011-09-12

      JDK linux 下安裝 

       

      1.          把安裝文件放在 /opt 下,并執(zhí)行

      [root@localhost opt]# ./jdk-1_5_0_06-linux-i586.bin

          并輸入 yes 確認(rèn)安裝

       

      2.         創(chuàng)建 /etc/profile.d/java.sh 編輯環(huán)境變量

      export JAVA_HOME=/opt/jdk

      export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

      export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

       并執(zhí)行

      [root@localhost profile.d]# source java.sh

       

      3.         驗(yàn)證 輸入 javac 出現(xiàn)提示信息

      4.         執(zhí)行 helloworld  小程序

      /opt/test 下建立 HelloWorld.java

      public class HelloWorld{

       

        public static void main(String args[]){

          HelloWorld hello=new HelloWorld();

          hello.printHello();

        }

       

        private void printHello(){

          System.out.println("hello!!!");

        }

      }

      執(zhí)行結(jié)果

      [root@localhost test]# javac HelloWorld.java

      [root@localhost test]# java HelloWorld

      hello!!!

       

      TOMCAT Linux 下的安裝

       

      1.          把安裝文件放在 /opt 下,并且解壓文件

       

      [root@localhost opt]# unzip apache-tomcat-5.5.28.zip

       

      2.          修改安裝文件下的 bin/下的權(quán)限,使其具有執(zhí)行的權(quán)限

      [root@localhost tomcat]# chmod 755 -R bin/

       

      3.          啟動(dòng) tomcat

      [root@localhost bin]# ./startup.sh

      結(jié)果:

      Using CATALINA_BASE:   /opt/tomcat

      Using CATALINA_HOME:   /opt/tomcat

      Using CATALINA_TMPDIR: /opt/tomcat/temp

      Using JRE_HOME:        /opt/jdk

      Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar

       

      4.         驗(yàn)證tomcat 安裝成功

      在瀏覽器中輸入http://localhost:8080 如出現(xiàn)   TOMCAT 初始界面說明配置成功。

      如果出現(xiàn)其他頁面,則端口被占用,需要修改 TOMCAT 的端口號。

       

       

      MYSQL Linux下的安裝

      (1)       執(zhí)行"groupadd mysql"添加組mysql用戶組。在mysql 組下增加 mysql 用戶

      [root@localhost etc]# groupadd mysql

      [root@localhost etc]# useradd -g mysql mysql

       

             執(zhí)行后查看確認(rèn)

      [root@localhost etc]# cd /home/

      [root@localhost home]# ll

      total 32

      drwx------  2 root  root  16384 Oct 25  2009 lost+found

      drwx------  2 lto   lto    4096 Oct 25  2009 lto

      drwx------  2 mysql mysql  4096 Oct 25 01:01 mysql

       

       

           

       

      (2)  opt 目錄下解壓mysql安裝文件

          [root@localhost opt]# tar -zxvf mysql-5.0.0-alpha.tar.gz

       

          

      (3) 安裝mysql (在解壓的目錄下執(zhí)行 configure 程序 設(shè)置安裝路徑 )

           [root@localhost mysql-5.1.30]# ./configure -prefix=/opt/mysql

       

       4)出現(xiàn)Thank you for choosing MySQL! 執(zhí)行make 進(jìn)行編譯 再執(zhí)行 make install 安裝

      [root@localhost mysql-5.1.30]# make

      [root@localhost mysql-5.1.30]# make install

       

      5)以mysql 的身份進(jìn)行安裝

       [root@localhost bin]# ./mysql_install_db --user=mysql

       

      (6)修改相應(yīng)文件的主屬,和組屬

      [root@localhost bin]# chown -R root .

      [root@localhost bin]# chown -R mysql var

      [root@localhost bin]# chgrp –R mysql .

       

      (7) mysql 的身份啟動(dòng)數(shù)據(jù)庫

      [root@localhost bin]./bin/mysqld_safe --user=mysql

      結(jié)果:

      091025 23:50:49 mysqld_safe Logging to '/opt/mysql/var/localhost.localdomain.err'.

      091025 23:50:50 mysqld_safe A mysqld process already exists

       

      8)驗(yàn)證數(shù)據(jù)庫的安裝 (默認(rèn)安裝后 root 是沒有密碼的 進(jìn)入數(shù)據(jù)庫直接回車)

      [root@localhost bin]# ./mysql -u root -p

      Enter password:

      Welcome to the MySQL monitor.  Commands end with ; or \g.

      Your MySQL connection id is 5

      Server version: 5.1.30 Source distribution

       

      Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

       

      mysql>

       
       
       

      Mysql 的基本操作

      1.          修改用戶密碼

      因?yàn)?/span> root 用戶初始沒有密碼 所以直接修改

         [root@localhost bin]# ./mysqladmin -u root -password 123456

      為已有密碼的用戶修改密碼

         [root@localhost bin]# ./mysqladmin -u root -p111111 password 123456

       

      2.          查看數(shù)據(jù)庫

      在進(jìn)入數(shù)據(jù)庫后輸入 show databases; ( 注意分號 )

        mysql> show databases;

      +--------------------+

      | Database           |

      +--------------------+

      | information_schema |

      | mysql              |

      | redmoonoa          |

      | test               |

      +--------------------+

      4 rows in set (0.07 sec)

       

      3.          進(jìn)入數(shù)據(jù)庫

        mysql> use test

      Database changed

       

      4.          查看數(shù)據(jù)庫中的表

      mysql> show tables;

      Empty set (0.00 sec)

       

      5.          建數(shù)據(jù)庫、表、

      mysql> create database mysql_test

          -> ;

      Query OK, 1 row affected (0.02 sec)

       

      mysql> use mysql_test;

      Database changed

         mysql> create table users ( id int(3) auto_increment not null primary key, namechar(10) not null, pwd char(10) not null);

      Query OK, 0 rows affected (0.04 sec)

         驗(yàn)證:

        mysql> describe users // 查看表結(jié)構(gòu)

          -> ;

      +-------+----------+------+-----+---------+----------------+

      | Field | Type     | Null | Key | Default | Extra          |

      +-------+----------+------+-----+---------+----------------+

      | id    | int(3)   | NO   | PRI | NULL    | auto_increment |

      | name  | char(10) | NO   |     | NULL    |                |

      | pwd   | char(10) | NO   |     | NULL    |                |

      +-------+----------+------+-----+---------+----------------+

       

         插入數(shù)據(jù):

        mysql> insert into users(name,pwd) values('user1','123456');

      Query OK, 1 row affected (0.00 sec)

       

      mysql> insert into users(name,pwd) values('admin','123456');

      Query OK, 1 row affected (0.01 sec)

      驗(yàn)證:

      mysql> select * from users

          -> ;

      +----+-------+--------+

      | id | name  | pwd    |

      +----+-------+--------+

      |  1 | user1 | 123456 |

      |  2 | admin | 123456 |

      +----+-------+--------+

      2 rows in set (0.00 sec)

       

      linux 下搭建 jdk+tomcat+mysql 應(yīng)用

        通過一個(gè)簡單的 jsp 頁面, 驗(yàn)證 數(shù)據(jù)庫,服務(wù)器 環(huán)境配置的正確。

       

      1.            編寫 JSP 程序

      tomcat/wapapps 文件夾下,建立文件夾 sql_test

      sql_test 下建立文件 test.jsp

      test.jsp 中敲入下面程序

      <%@ page contentType="text/html; charset=gb2312" language="java" 

      import="java.sql.*"%>

      <meta http-equiv="Content-Type" content="text/html; charset=gb2312">

      <%

       

          String server="localhost";       

          String dbname="mysql_test";         

          String user="root";               

          String pass="123456";           

          String port="3306";   

         

       

          String url ="jdbc:mysql://"+server+":"+port+"/"+dbname+"?user="+user+"&password="+pass;

       

          Class.forName("com.mysql.jdbc.Driver").newInstance();

       

          Connection conn= DriverManager.getConnection(url);

       

          Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

       

         

         

          String sql="select name,pwd from users";

          ResultSet rs=stmt.executeQuery(sql);

       

          while(rs.next()){

          out.print("username:");

          out.print(rs.getString("name")+" password:");

          out.println(rs.getString("pwd")+"<br>");

          }

          rs.close();

          stmt.close();

          conn.close();

      %>

       

      2.            配置 JDBC 驅(qū)動(dòng)

      下載相應(yīng) JDBC  驅(qū)動(dòng) 

      mysql-connector-java-3.1.8-bin.jar

      把驅(qū)動(dòng)放在  sql_test 下建立文件夾 /WEB-INF/lib

      3.            運(yùn)行程序

      在瀏覽器中,輸入 http://127.0.0.1:8080/sql_test/test.jsp

      出現(xiàn)結(jié)果

      username:user1 password:123456

      username:admin password:123456

      證明系統(tǒng)運(yùn)行正常

       

      下面是程序文件,可以直接放在tomcat的 webapps 下運(yùn)行

       

        本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多