:::MySQLÀÛ¾÷:::::::::::::: Microsoft Windows 2000 [Version 5.00.2195] (C) Copyright 1985-2000 Microsoft Corp. C:\Documents and Settings\Administrator>cd.. C:\Documents and Settings>cd.. C:\>cd \mysql -u apple -p ÁöÁ¤µÈ °æ·Î¸¦ ãÀ» ¼ö ¾ø½À´Ï´Ù. C:\>cd \mysql -u root -p ÁöÁ¤µÈ °æ·Î¸¦ ãÀ» ¼ö ¾ø½À´Ï´Ù. C:\>cd \mysql -u root -p ÁöÁ¤µÈ °æ·Î¸¦ ãÀ» ¼ö ¾ø½À´Ï´Ù. C:\>mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 to server version: 4.0.22-nt Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> create database appledb; Query OK, 1 row affected (0.09 sec) mysql> grant all on appledb. * to apple@localhost identified by '1234'; Query OK, 0 rows affected (0.16 sec) mysql> exit Bye C:\>mysql -u apple -p Enter password: **** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 to server version: 4.0.22-nt Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> exit Bye C:\>cd mssql ÁöÁ¤µÈ °æ·Î¸¦ ãÀ» ¼ö ¾ø½À´Ï´Ù. C:\>cd mysql C:\mysql>cd bin C:\mysql\bin>mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 80 to server version: 4.0.22-nt Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create database JspTestDB; Query OK, 1 row affected (0.02 sec) mysql> use database ERROR 1049: Unknown database 'database' mysql> use database; ERROR 1049: Unknown database 'database' mysql> use JspTestDB Database changed mysql> create table starcraft(id varchar(20), -> name varchar(30), -> price int(10)); Query OK, 0 rows affected (0.06 sec) mysql> insert into statcraft values ('aa1', '¸¶¸°', 50); ERROR 1146: Table 'jsptestdb.statcraft' doesn't exist mysql> insert into starcraft values ('aa1', '¸¶¸°', 50); Query OK, 1 row affected (0.00 sec) mysql> insert into starcraft values ('aa2', 'µå·¡°ï',250); Query OK, 1 row affected (0.00 sec) mysql> insert into starcraft values ('aa3', 'ĵµð',150); Query OK, 1 row affected (0.00 sec) mysql> insert into starcraft values ('aa4', 'È÷µå¶ó',75); Query OK, 1 row affected (0.00 sec) mysql> insert into starcraft values ('aa5', '»½ÀÌ¿ä',150); Query OK, 1 row affected (0.00 sec) mysql> select * from starcraft; +------+--------+-------+ | id | name | price | +------+--------+-------+ | aa1 | ¸¶¸° | 50 | | aa2 | µå·¡°ï | 250 | | aa3 | ĵµð | 150 | | aa4 | È÷µå¶ó | 75 | | aa5 | »½ÀÌ¿ä | 150 | +------+--------+-------+ 5 rows in set (0.00 sec) mysql> :::DB¿¬°á::::::::::::::::: ***JdbcExam.jsp <%@ page contentType="text/html;charset = euc-kr" import="java.sql.*"%> <%! private String driver="org.gjt.mm.mysql.Driver"; private String user="root"; private String pass=""; private String dbURL="jdbc:mysql://localhost:3306/jspTestDB"; private String sql="select * from starcraft"; private Connection connection; private Statement stmt; private ResultSet result; private String id; private String name; private int price; %>

½ºÅ¸Å©·¡ÇÁÆ® À¯´Ö

<% try{ Class.forName(driver); connection=DriverManager.getConnection(dbURL,user,pass); stmt=connection.createStatement(); result=stmt.executeQuery(sql); while(result.next()){ id=result.getString("id"); name=result.getString("name"); price=result.getInt("price"); %> <% } }catch(SQLException se){ out.println(se.getMessage()); }catch(ClassNotFoundException cne){ out.println("jdbc driver not founded!"); } %>
ID
À¯´Ö¸í
°¡°Ý
<%=id%>
<%=name%>
<%=price%>
jsp½ºÅ͵ð 2004 11 26 ¼Ò½ºÀÚ¼¼È÷º¸±â: http://www.6VJ.com/jsp/jsp1126.txt http://www.6VJ.com/jsp/jsp1126.html