⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.java

📁 Spring2.0宝典
💻 JAVA
字号:
package lee;

import java.util.List;
import java.util.Iterator;

import javax.sql.DataSource;
import com.mchange.v2.c3p0.ComboPooledDataSource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

import java.util.*;
import java.sql.*;
import org.springframework.jdbc.object.SqlFunction;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.core.SqlOutParameter;

import oracle.jdbc.OracleTypes;


/**
 * @author  yeeku.H.lee kongyeeku@163.com
 * @version  1.0
 * Copyright (C), 2005-2008, yeeku.H.Lee
 * This program is protected by copyright laws.
 * Program Name:
 * Date: 
 */

public class Test
{
	
	public static void main(String[] args)throws Exception
	{

		ComboPooledDataSource ds = new ComboPooledDataSource();
		ds.setDriverClass("oracle.jdbc.driver.OracleDriver");
		ds.setJdbcUrl("jdbc:oracle:thin:@localhost:1521:ora9i");
		ds.setUser("scott");
		ds.setPassword("tiger");
        ds.setMaxPoolSize(40);
        ds.setMinPoolSize(2); 
        ds.setMaxStatements(180); 

		
		//调用函数
		SqlFunction sf1 = new SqlFunction(ds,"select GETDEPT_FUN(3) from dual");
		sf1.compile();
		Map in = new HashMap();
		in.put("deptndo",new Integer(4));
		List m = sf1.execute(in);
		for (Iterator it = m.iterator();it.hasNext() ; )
		{
			ResultSet rs = (ResultSet)it.next();
			while (rs.next())
			{
				System.out.println(rs.getString(2));
			}
		}
		//执行简单查询
		SqlFunction sf2 = new SqlFunction(ds,"select count(*) from dept");
		sf2.compile();
		System.out.println(sf2.run());
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -