: SQL. SQL Plus. JDBC.
SQL >> SQL create table : CREATE TABLE ( ( ), ( ),.. )
SQL >> SQL create table : id username dept birth email id username dept birth email CREATE TABLE member ( id NUMBER NOT NULL Primary Key, username VARCHAR2(20), dept VARCHAR2(7), birth DATE, email VARCHAR2(40) )
SQL >> SQL alter table : ALTER TABLE [SQL ] ( )
SQL >> SQL alter table : id id username dept birth email email tel ALTER TABLE member add (tel varchar2(30) NOT NULL) ALTER TABLE member modify (username varchar2()) ALTER TABLE member DROP CONSTRAINT member_pk
SQL >> SQL delete table : DROP TABLE.
SQL >> SQL select : SELECT FROM WHERE
SQL >> SQL select : id username dept birth email 200701 85.08. test@test.net 200702 85..02 tt@tt.net SELECT * FROM member WHERE id = 200201 SELECT id, username, birth FROM member WHERE id = 200201 AND name=
SQL >> SQL insert : INSERT INTO ( ) VALUES( )
SQL >> SQL insert : id username dept birth email 200701 85.08. test@test.net 200702 85..02 tt@tt.net 200703 85.04.12 my@my.net INSERT INTO member values(200203,,, 82.04.12, my@my.net )!. INSERT INTO member(id,gwa,name) values(200201,, )!.
SQL >> SQL update : UPDATE set = 1, field = 2 WHERE
SQL >> SQL update : id username dept birth email 200701 85.08. test@test.net 200702 85..02 tt@tt.net 200705 UPDATE member set id = 200205, name= WHERE id = 200202
SQL >> SQL delete : DELETE FROM WHERE
SQL >> SQL delete : id username dept birth email 200701 85.08. test@test.net 200702 85..02 tt@tt.net DELETE FROM member WHERE id = 200201 DELETE FROM member WHERE id = 200201 AND name=
SQL >> SQL PL/SQL SQL.. SQL Plus!
JDBC >> JDBC.. DB JDBC.
JDBC >> JDBC JDBC JDBC JDBC MySql JDBC DBMS MySql DBMS JDBC DBMS
JDBC >> JDBC JDBC JDBC API JDBC JDBC API JDBC-ODBC Native-API Net-Protocol Native-Protocol ODBC JDBC DBMS DBMS DBMS DBMS DBMS
JDBC >> JDBC 2003 4 : 2.0 (3.0 ) JDBC http://otn.oracle.com/software/tech/java/sqlj_jdbc/htdocs/jdbc9201.htm CD\ojdbc14.jar ( ) %JAVA_HOME%\jre\lib\ext\. tomcat4\common\lib Context\WEB-INF\lib tomcat4\common\lib
JDBC >> JDBC
JDBC >> JDBC Class.forName( oracle.jdbc.driver.oracledriver ); DB : sun.jdbc.odbc.jdbcodbcdriver
JDBC >> JDBC Connection conn = DriverManger.getConnection(JDBC_url,, ); JDBC_URL = JDBC:oracle:thin:@IP : :SID DB = jdbc:odbc:song IP IP 1521 SID MySQL DB
JDBC >> JDBC Statement Statement stmt = conn.createstatement(); stmt.executeupdate( insert into test values('" +request.getparameter("username")+"','"+request.getparameter("email")+"')");
JDBC >> JDBC PreparedStatement PreparedStatement pstmt = conn.preparestatement( insert into test values(?,?) ); pstmt.setstring(1,request.getparameter("username"); pstmt..setstring(2, request.getparameter("email"); pstmt.executeupdate();
JDBC >> JDBC ResultSet rs = pstmt.executequery( ); ResultSet next()
JDBC >> JDBC Select * from xxx where city= ; rs rs.next() rs.next() 0 ResultSet 1 4 name email city ========================== test@test.net kk@kk.net tt@tt.net hh@hh.net...
JDBC >> JDBC ResultSet rs = pstmt.executequery(); while(rs.next()) { name = rs.getstring(1); // or rs.getstring( name ); age = rs.getint(2); // or rs.getint( email ); } rs.close();
JDBC >> JDBC Connection close(). DB. <jsp:usebean id= mybean scope= request class= MyBean />
JDBC >> JDBC JDBC DB DB : server IP, DB userid, userpass, SID(DB) ( ) DB 1 DB 2 DB 3
JDBC >> JDBC Statement PreparedStatement