易截截图软件、单文件、免安装、纯绿色、仅160KB

java操作oracle数据库

 package com.chinacache.boss.queryservice.service.impl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.chinacache.boss.queryservice.exception.BusinessException;
import oracle.sql.ArrayDescriptor;
public class Main {
public static void main(String[] args) throws Exception {
Connection conn = null;
PreparedStatement pstmt = null;
java.sql.Array sqlArray = null;
conn = getOracleConnection();
// For oracle you need an array descriptor specifying
// the type of the array and a connection to the database
// the first parameter must match with the SQL ARRAY type created
ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor(
"CHAR_ARRAY", conn);// CREATE OR REPLACE TYPE CHAR_ARRAY AS table OF VARCHAR2(255)
// then obtain an Array filled with the content below
String[] content = { "5137", "V2", "V3", "V4" };
sqlArray = new oracle.sql.ARRAY(arrayDescriptor, conn, content);
pstmt = conn.prepareStatement(""
+ "select * "
+ "from bandwith_area_test t where t.channel_id in (select * from the (select cast(? as CHAR_ARRAY) from dual)) and t.area_id = ?" + "and t.day >= ? and t.day <= ? order by t.day");
Date start = null;
Date end = null;

try {
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmm");
start = df.parse("200907011000");
end = df.parse("200907012000");
} catch (ParseException e) {
e.printStackTrace();
throw new BusinessException(e.getMessage());
}

pstmt.setArray(1, sqlArray);
pstmt.setString(2, "9050");
pstmt.setDate(3, new java.sql.Date(start.getTime()));
pstmt.setDate(4, new java.sql.Date(end.getTime()));
int rowCount = pstmt.executeUpdate();
System.out.println("rowCount=" + rowCount);
System.out.println("--Demo_PreparedStatement_SetArray end--");
pstmt.close(


相关文档:

Web服务技术,且看《Java Web服务》为您一一道来

 
【书名】Java Web服务:构建与运行
【原书名】Java Web Services : Up and Running
【作者】Martin Kalin
【译者】任增刚
【出版社】电子工业出版社    
【书号】9787121097119
【上市日期】2009年11月
【内容简介】
 本书以示例驱动的方式详尽地介绍了XML Web服务和RESTful ......

java汉字字符串按拼音排序

目标:实现一个汉字字符串按汉语拼音字典顺序排序。
原理:在windows环境的gbk字符集里,汉字是按汉语拼音字典顺序编码的,如“础”是B4A1,“储”是B4A2。这里有个问题就像上面的储和础这样的同音字只能遵照编码的顺序了,另外多音字也得遵照编码顺序。设计思路是先拆分汉字字符串为字符数组,获得每 ......

java基本数据类型与其封装类

 1   Boolean VS boolean
public final class Booleanextends [url=file:///G:/html_zh_CN/html/zh_CN/api/java/lang/Object.html]Object[/url]implements [url=file:///G:/html_zh_CN/html/zh_CN/api/java/io/Serializable.html]Serializable[/url], [url=file:///G:/html_zh_CN/html/zh_CN/api/java/lang ......

java文件操作大全

一.获得控制台用户输入的信息
Java代码
/** */
/**获得控制台用户输入的信息
 
     * @return
 
     * @throws IOException
 
     */
  
    public
  ......

java获得当前时间一小时前的时间,格式化成yyyy

       /**
     * 获得当前时间一小时前的时间,格式化成yyyy-MM-dd HH:mm:ss:SS<br>
     *
     * @return 当前时间一小时前的时间
     */
    public String getOneHours ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号