- 0
- 0
- 约7.24千字
- 约 9页
- 2017-12-22 发布于河南
- 举报
讲义JDBCReview
讲义JDBCReview
Module 1 2 JDBC Overview Using JDBC
* JDBC API : java.sql, javax.sql
* Creating a Basic JDBC Application: (DriverManager, Driver, Connection, Statement, PreparedStatement, ResultSet)
1. Register driver
3 ways: * Class.forName(driverName);
* Driver dr=new XDriver();
* java -Djdbc.drivers=driverName[:driverName]
2. Establish a connection to the Database
2 ways * Connection con=DriverManager.getConnection(databaseURL, userID, password);
* Connection con=dr.connect(urlString, propertiesInfo);
3. Create a statement
3 statements: * Statement st=con.createStatement();
* PreparedStatement pst=con.prepareStatement(sqlString);
* CallableStatement
4. Executing SQL
* st.execute(sqlString); //pst.setXXXX(?,?); pst.execute();
* ResultSet rs=st.executeQuery(sqlString); // pst.setXXXX(?,?); ResultSet rs=pst.executeQuery();
* st.executeUpdate(sqlString); // pst.setXXXX(?,?); pst.executeUpdate();
5. Processing ResultSet
while(rs.next())
XXX x= rs.getXXX(..); // be careful: data type (java - Sql )
6. close : rs, st, pst, con
Module 3 OOAD and Database Design
Mapping: 1. classes - tables
one table - each class
one table - each concrete class //inheritance
one table - an entire class hierarchy //inheritance
2. attributes - columns : class type - SQL type
3. class relationship - tables
1) 1 (pk1, fk1) - 1 (pk2, fk2)
fk1 ref to pk2, fk2 ref to pk1
2) 1 (pk1) - * (pk2, fk2)
fk2 ref to pk1
3) * (pk1 ) - * (pk2)
change to : two 1 - *
1 (pk1) - * (pk3, fk1, fk2) - 1 (pk2)
您可能关注的文档
最近下载
- MEMS NEMS 概论.ppt
- 伯克利课程 - MEMS设计 Introduction to MEMS design.ppt VIP
- 2019 上海地区地区潮汐表(吴淞).pdf VIP
- 《光伏材料检测技术》课件——太阳电池片IV特性检测.pptx VIP
- 《NEMS纳米机电系统》课件.ppt VIP
- 资质认定评审员网上测试模拟试卷及答案.docx VIP
- 《光伏材料检测技术》课件——光伏组件的电性能测试.pptx VIP
- mems nems 概论经典案例.ppt VIP
- nems与微机电系统mems-国立高雄第一科技大学.ppt VIP
- T_ZZB 2587—2021_汽车热管理系统用电子膨胀阀.pdf VIP
原创力文档

文档评论(0)