employee.java
来自「Java示例100」· Java 代码 · 共 67 行
JAVA
67 行
/** * filename: Employee.java * * This demonstrates how to derive a user-defined type * based on ORAData and ORADataFactory. * This class is used by ORADataExample.java * * Please use jdk1.2 or later version, classes12.zip **/import java.math.BigDecimal;import java.sql.SQLException;import java.sql.Connection;import oracle.jdbc.OracleConnection;import oracle.sql.*;public class Employee implements ORAData, ORADataFactory{ static final Employee _employeeFactory = new Employee(null, null); public static ORADataFactory getFactory() { return _employeeFactory; } public Employee () { } /* constructor */ public Employee(String empName, BigDecimal empNo) { this.empName = empName; this.empNo = empNo; } /* ORAData interface */ public Datum toDatum(Connection c) throws SQLException { StructDescriptor sd = StructDescriptor.createDescriptor("HR.EMPLOYEE", c); Object [] attributes = { empName, empNo }; return new STRUCT(sd, c, attributes); } /* ORADataFactory interface */ public ORAData create(Datum d, int sqlType) throws SQLException { if (d == null) return null; Object [] attributes = ((STRUCT) d).getAttributes(); return new Employee((String) attributes[0], (BigDecimal) attributes[1]); } /* fields */ public String empName; public BigDecimal empNo;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?