首页 > 数据库技术 > 详细

java调用oracle函数

时间:2015-06-11 16:57:17      阅读:192      评论:0      收藏:0      [点我收藏+]
/**
	 * 调用函数取得数据表的ID值 
	 * @param tableName 表名
	 * @return
	 * @throws SQLException
	 */
	public String callFun(String tableName) throws SQLException {
		Connection conn = ConnectionFactory.getConnection();
		CallableStatement cstmt = null;
		cstmt = conn.prepareCall("{?=call getIdBySeq(?)}");
		cstmt.registerOutParameter(1, Types.VARCHAR);
		cstmt.setString(2, tableName);
		cstmt.execute();
		return cstmt.getString(1);
	}

public class ConnectionFactory {

	private ConnectionFactory() {
	}

	private static ComboPooledDataSource ds = null;

	public static synchronized Connection getConnection() {   
        Connection con = null;   
        ds = new ComboPooledDataSource();
        try {   
            con = ds.getConnection();   
        } catch (SQLException e1) {   
            e1.printStackTrace();   
        }   
        return con;   
    }   
}


java调用oracle函数

原文:http://blog.csdn.net/xiongwt/article/details/46458083

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!