易截截图软件、单文件、免安装、纯绿色、仅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中四种操作xml方式的比较以及四种方法的简单例子

xml的应用越来越广泛,趁无事时,找了一篇文章转过来,以备以后学习。以下是文章内容。
 1. 介绍
    1)DOM(JAXP Crimson解析器)
    DOM是用与平台和语言无关的方式表示XML文档的官方W3C标准。DOM是以层次结构组织的节点或信息片断的集合。这个层次结构允许开发人员在树中寻找特 ......

Java Filter 过滤器的使用

1、建立一个Servlet并且实现Filter接口
该类需要实现Filter接口中的init()   doFilter()    destory()方法
其中init()方法自动在项目启动的时候加载,doFilter()在调用xml配置的路径是加载,destory()方法在退出项目的时候进行。
 
public class TestFilter implements Filter{
  ......

JAVA秘密

 好久了,都想向学习JAVA的新人写点东西,因为我实在看不下去了,看不下去很多误导JAVA学习者的观点,遍及天下!网络让好的东西流行,可是往往也让错的东西出现的次数多了变的好像正确了,三人成虎,指鹿为马似乎在网络里更加容易发生,好了废话不说,请看我细细向你道来。
  秘密一,学习JAVA好未必可以找到JA ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号