java.sql 包中包含用于以下方面的 API:
通过 DriverManager 实用程序建立与数据库的连接
DriverManager 类:建立与驱动程序的连接
SQLPermission 类:代码在 Security Manager(比如 applet)中运行时提供权限,试图通过 DriverManager 设置一个记录流
Driver 接口:提供用来注册和连接基于 JDBC 技术(“JDBC驱动程序”)的驱动程序的 API,通常仅由 DriverManager 类使用
DriverPropertyInfo 类:提供 JDBC 驱动程序的属性,不是供一般用户使用的向数据库发送 SQL 语句
Statement:用于发送基本 SQL 语句
PreparedStatement:用于发送准备好的语句或基本 SQL 语句(派生自 Statement)
CallableStatement:用于调用数据库存储过程(派生自 PreparedStatement)
Connection 接口:提供创建语句以及管理连接及其属性的方法
Savepoint:在事务中提供保存点
获取和更新查询的结果
ResultSet 接口
SQL 类型到 Java 编程语言中的类和接口的标准映射关系
Array 接口:SQL ARRAY 的映射关系
Blob 接口:SQL BLOB 的映射关系
Clob 接口:SQL CLOB 的映射关系
Date 类:SQL DATE 的映射关系
NClob 接口:SQL NCLOB 的映射关系
Ref 接口:SQL REF 的映射关系
RowId 接口:SQL ROWID 的映射关系
Struct 接口:SQL STRUCT 的映射关系
SQLXML 接口:SQL XML 的映射关系
Time 类:SQL TIME 的映射关系
Timestamp 类:SQL TIMESTAMP 的映射关系
Types 类:提供用于 SQL 类型的常量
自定义映射 SQL 用户定义类型 (UDT) 到 Java 编程语言中的类
SQLData 接口:指定 UDT 到此类的一个实例的映射关系
SQLInput 接口:提供用来从流中读取 UDT 属性的方法
SQLOutput 接口:提供用来将 UDT 属性写回流中的方法
元数据
DatabaseMetaData 接口:提供有关数据库的信息
ResultSetMetaData 接口:提供有关 ResultSet 对象的列的信息
ParameterMetaData 接口:提供有关 PreparedStatement 命令的参数的信息
异常
SQLException:由大多数方法在访问数据出问题时抛出,以及因为其他原因由其他一些方法抛出
SQLWarning:为了指示一个警告而抛出
DataTruncation:为了指示数据可能已经被截断而抛出
BatchUpdateException:为了指示并不是批量更新中的所有命令都成功执行而抛出
分别是:msbase.jar,mssqlserver.jar,msutil.jar这三个包http://www.res-china.com/u1032457
这里免费下载
Oracle 官方网页上有这段解释,就是说我们如何把一个 SQL 东西翻译成一个 Java 类型的。比如,一个 Date 列翻译成 java.sql.Date,一个 number(1) 翻译成 boolean 而不是 integer。
至于如何使用这个类型映射,你先在调试模式下看一下它原来返回的 getTypeMap() 是什么样的,里面应该已经有默认的翻译,只是不支持自定义的 SQL Type,比如 Java 类型或其它数据库特有的类型。
Parameters:columnIndex - the first column is 1, the second is 2, ...
map - a java.util.Map object that contains the mapping from SQL type names to classes in the Java programming language
Returns:
an Object in the Java programming language representing the SQL value
另外一段:说 connection.getTypeMap() 演示我们把一个自定义的类型 mySchemaName.ATHLETES 的字段翻译成 Athletes 的 java 字段。
A user may create a new type map, which is a java.util.Map object, make an entry in it, and pass it to the java.sql methods that can perform custom mapping. In this case, the method will use the given type map instead of the one associated with the connection.
For example, the following code fragment specifies that the SQL type ATHLETES will be mapped to the class Athletes in the Java programming language. The code fragment retrieves the type map for the Connection objectcon, inserts the entry into it, and then sets the type map with the new entry as the connection's type map.
java.util.Map map = con.getTypeMap()
map.put("mySchemaName.ATHLETES", Class.forName("Athletes"))
con.setTypeMap(map)
再说说写一个自己的自定义类型:
http://docs.oracle.com/javase/tutorial/jdbc/basics/sqlcustommapping.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.html#getObject(int,%20java.util.Map)