Title: ? JDBC??
1???? JDBC
? JDBC?? ? JDBC???? ? JDBC API ? JDBC???
2JDBC??
? JDBC???Java Applet????????????? ????API?? ?
JDBC?????????? ??JDBC???,??????SQL??????
JAVA???
3JDBC????
4??????????
5??????????
6JDBC?ODBC
? ODBC API?C ????,?JAVA?????????? ?
?????????,???ODBC C API ????? JAVA
API? ???JDBC????????JAVA???????
7JDBC ????
8JDBC ????
? JDBC-ODBC?(JDBC-ODBC bridge) JDBC???ODBC
?????ODBC???client??? ?????????? ???API??JAVA??
(Native-API partly-Java driver) JDBC?? ?
????Client ?API,???????? ????? ???????JAVA??(J
DBC-Net pure Java driver) JDBC?? ?
?????DBMS?????,??? ??????????????DBMS??? ?????
??JAVA??(Native-protocol pure Java driver)
JDBC?? ???DBMS??????
9JDBC API ??
?????????? ???SQL?? ?????
10JDBC API ?
?? JDBC?
Java.sql.Driver java.sql.DriverManager java.sql.Dr
ivePropertyInfo
??????
?????
Java.sql.Connection
java.sql.Statement java.sql.PreparedStatement java
.sql.CallableStatement
SQL??
??
java.sql.ResultSet
??
java.sql.SQLException java.sql.SQLWarning
11JDBC ???
???????
??
??
??
??
??
????
?????
executeUpdate( )
???
executeQuery( )
???
execute( )
??
getMoreResults( )
getResultsSet( )
12?????????
- ? JDBC?DriverManager?????????Driver????
- ?????java.sql???Driver???,??????
- ??????Class.forName( )?????????Driver?
- ?Class.forName(sun.jdbc.odbc.JdbcOdbcDrive
r), - ??JDBC-ODBC??
- ???DriverManager.getConnection( )????????
- ??????URL,???????????????
- ???
- ????jdbcltsubprotocolgtltsubnamegt
- ???JDBC-ODBC?????wombat????????
- Connection con DriverManager.getConnection(jdbc
odbc - wombat,username,password)
13??SQL??
??????????Statement??,???SQL?? ??????????? /
??SQL????????rs / Statement stmt
con.createStatement( ) ResultSet rs
stmt.executeQuery( SELECT a, b, c FROM
Table1) ?????????????SQL??,???? PreparedStateme
nt ??? ???CallableStatement??????????????
14?????
????????????????????? ??????????(Cursor)??????????
? SQL?????JAVA??????? ??SQL
???????,???????????? /????? rs/ while
(rs.next( )) int x rs.getInt(a) String s
rs.getString(b) float f
getFloat(c) stmt.close( ) con.close( )
15JDBC?????
- ? JDBC????SQL??,??????API?
- ??JDBC????????
- JAVA???SQL SQLJ,?JAVA???????
- ????SQL???
- ?????????JAVA?,JAVABland?