ibatis2.x调用oracle存储过程

阅读更多
一.JAVA对象
public class User implements Serializable {
 
    private static final long serialVersionUID = -6919964218508186044L;  
    private int id;  
    private String name;  
    private Date birthday;
   
    public int getId() {  
        return id;  
    }  
    public void setId(int id) {  
        this.id = id;  
    }  
    public String getName() {  
        return name;  
    }  
    public void setName(String name) {  
        this.name = name;  
    }  
    public Date getBirthday() {  
        return birthday;  
    }  
    public void setBirthday(Date birthday) {  
        this.birthday = birthday;  
    }  
} 
  
二.JAVA对象对应XML配置
 

 
     
         
         
     
 
     
     
        {call getAllUser(?)}  
    
     
      
     
 
三.ibatis总配置



 
 
 
  
   
   
   
   
   
   
   
   
   
   
   
   
   
  
 
 

  
 总配置对应的属性文件jdbc.properties
#jdbc属性配置信息
#ORACLE
jdbc.url=jdbc:oracle:thin:@192.168.1.100:1521:orcl
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.username=haiya
jdbc.password=kingdee
jdbc.testsql=select 1 from dual
  
四.调用主类
public class Test {
 private static SqlMapClient sqlMapper;
 
 static {
  Reader reader = null;
  try {
   reader = Resources.getResourceAsReader("SqlMapConfig.xml");
   sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
  } catch (Exception e) {
   e.printStackTrace();
  } finally {
   if(reader != null) {
    try {
     reader.close();
    } catch (IOException e) {
     e.printStackTrace();
    } finally {
     reader = null;
    }
   }
  }
 }
 
 public static void main(String[] args) {  
     try {
      User user = null;
      List userList = sqlMapper.queryForList("getAllUser");
      for(int i=0;i   
  

你可能感兴趣的:(数据库,Oracle,ibatis,java)